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

Principle:AKSW RDFUnit Pattern Based Test Generation

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

Overview

Technique for automatically generating data-quality test cases by instantiating SPARQL-based pattern templates with bindings derived from schema introspection.

Description

Pattern-Based Test Generation is the core mechanism by which RDFUnit creates validation tests without requiring users to write individual test cases by hand. It works by defining reusable Test Auto-Generators (TAGs): SPARQL queries that run against a schema's ontology to discover instances of pattern parameters (e.g., classes, properties, datatypes). Each TAG is associated with a Pattern: a parameterized SPARQL template that defines a generic validation check. When a TAG query returns results from a schema, each result row provides the bindings needed to instantiate the pattern into a concrete TestCase—a SPARQL query that checks for a specific data-quality violation in any dataset that claims conformance to that schema.

This approach addresses the scalability problem of writing individual tests for every combination of schema element and quality constraint. Instead, a small set of generic patterns (e.g., "every class instance must have a label") can be instantiated across any schema, producing comprehensive coverage automatically.

Usage

Use this principle when you need to validate RDF data against a schema and want automatic, comprehensive test coverage without manually authoring each test case. It is the default generation strategy in RDFUnit and applies to any OWL-based ontology. When SHACL shapes are also available, combine with Principle:AKSW_RDFUnit_SHACL_Constraint_Validation for complete coverage.

Theoretical Basis

A Pattern defines a parameterized SPARQL query template:

# Pattern template (abstract)
SELECT ?this WHERE {
  ?this a {{CLASS}} .
  FILTER NOT EXISTS { ?this {{PROPERTY}} ?value . }
}

A TAG (Test Auto-Generator) is a SPARQL query that runs against a schema to discover bindings:

# TAG query: finds all classes with a label annotation
SELECT ?CLASS ?DESCRIPTION WHERE {
  ?CLASS a owl:Class .
  ?CLASS rdfs:label ?DESCRIPTION .
}

For each result row, the TAG instantiates the pattern into a concrete test case:

# Abstract algorithm (not real implementation)
for result in tag_query.execute(schema_model):
    bindings = map_parameters(pattern.parameters, result)
    test_case = instantiate_pattern(pattern, bindings)
    test_suite.add(test_case)

The generated test case is a complete SPARQL query with the pattern parameters replaced by concrete values from the schema.

Related Pages

Implemented By

Uses Heuristics

Page Connections

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