Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AKSW RDFUnit TestExecutor Execute

From Leeroopedia
Knowledge Sources
Domains Semantic_Web, Test_Execution, Validation
Last Updated 2026-10-16 00:00 GMT

Overview

Abstract test execution engine that runs a test suite against a data source, collecting results through monitor callbacks.

Description

The TestExecutor abstract class defines the execution loop for running test cases against a `TestSource`. The `execute()` method iterates over all test cases in a `TestSuite`, executes each via `executeGenericTest()` (which dispatches to `executeSingleTest()` for individual test cases or `evaluateTestCaseGroup()` for logical constraint groups), determines the result status (Success, Fail, Error, Timeout), and notifies registered `TestExecutorMonitor` instances at each stage (start, per-test, finish).

Concrete subclasses implement `executeSingleTest()` and `getExecutionType()`:

  • StatusTestExecutor: Uses ASK queries, returns pass/fail status.
  • AggregatedTestExecutor: Uses COUNT queries, returns violation counts.
  • ShaclSimpleTestExecutor: Uses SELECT queries, returns individual violating nodes (SHACL Lite).
  • ShaclTestExecutor: Uses Extended SELECT queries, returns full SHACL results with annotations.

The `TestExecutorFactory.createTestExecutor()` factory selects the appropriate executor and query generation factory based on `TestCaseExecutionType`.

Usage

  • CLI validation: Created by `TestExecutorFactory.createTestExecutor()` in `ValidateCommand.call()`.
  • Programmatic validation: Created by `RDFUnitStaticValidator.validate()` internally.
  • JUnit integration: Subclassed by `RdfUnitJunitStatusTestExecutor` for JUnit test execution.

Code Reference

Source Location

  • Repository: AKSW/RDFUnit
  • File: rdfunit-core/src/main/java/org/aksw/rdfunit/tests/executors/TestExecutor.java, TestExecutorFactory.java

Signature

public abstract class TestExecutor {

    protected final QueryGenerationFactory queryGenerationFactory;
    private final Collection<TestExecutorMonitor> progressMonitors;

    public TestExecutor(QueryGenerationFactory queryGenerationFactory);

    abstract TestCaseExecutionType getExecutionType();

    protected abstract Collection<TestCaseResult> executeSingleTest(
        TestSource testSource, TestCase testCase) throws TestCaseExecutionException;

    public boolean execute(TestSource testSource, TestSuite testSuite);

    public void addTestExecutorMonitor(TestExecutorMonitor monitor);
    public void removeTestExecutorMonitor(TestExecutorMonitor monitor);
    public void cancel();
}

// Factory
public final class TestExecutorFactory {
    public static TestExecutor createTestExecutor(TestCaseExecutionType executionType);
    public static TestExecutor createTestExecutorWithCache(
        TestCaseExecutionType executionType, int cacheSize);
    public static TestExecutor createTestExecutor(
        TestCaseExecutionType executionType, QueryGenerationFactory qef);
}

Import

import org.aksw.rdfunit.tests.executors.TestExecutor;
import org.aksw.rdfunit.tests.executors.TestExecutorFactory;

I/O Contract

Inputs

Name Type Required Description
testSource TestSource Yes Dataset to execute tests against
testSuite TestSuite Yes Collection of test cases to execute
executionType TestCaseExecutionType Yes Determines executor type and query generation

Outputs

Name Type Description
execute() returns boolean true if all tests passed, false if any failed
monitor results TestExecution Collected by SimpleTestExecutorMonitor with TestCaseResults and DatasetOverviewResults

Usage Examples

Execute Test Suite (CLI pattern)

import org.aksw.rdfunit.tests.executors.TestExecutor;
import org.aksw.rdfunit.tests.executors.TestExecutorFactory;
import org.aksw.rdfunit.tests.executors.monitors.SimpleTestExecutorMonitor;
import org.aksw.rdfunit.enums.TestCaseExecutionType;

// Create executor for SHACL Lite results
TestExecutor executor = TestExecutorFactory.createTestExecutor(
    TestCaseExecutionType.shaclLiteTestCaseResult);

// Attach monitor to collect results
SimpleTestExecutorMonitor monitor = new SimpleTestExecutorMonitor();
monitor.setExecutionType(TestCaseExecutionType.shaclLiteTestCaseResult);
executor.addTestExecutorMonitor(monitor);

// Execute
executor.execute(dataset, testSuite);

// Get results
TestExecution results = monitor.getTestExecution();
DatasetOverviewResults overview = results.getDatasetOverviewResults();
System.out.println("Failed: " + overview.getFailedTests());

Execute with Cache

// Cached executor for repeated runs against different datasets
TestExecutor executor = TestExecutorFactory.createTestExecutorWithCache(
    TestCaseExecutionType.shaclTestCaseResult, 1000);
executor.addTestExecutorMonitor(monitor);
executor.execute(dataset1, testSuite);
executor.execute(dataset2, testSuite);  // reuses parsed queries

Related Pages

Implements Principle

Requires Environment

Uses Heuristics

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment