AKSW / RDFUnit

An RDF Unit Testing Suite
http://RDFUnit.aksw.org
Apache License 2.0
150 stars 40 forks source link

49 junit integration #51

Closed pepperbob closed 9 years ago

pepperbob commented 9 years ago

Hi Dimitris,

we started implementing the Runner and so far it looks quite promising. Though we need to add some features (CVs) and improve overall performance.

Maybe you can already have a glance. Feel free to comment.

Regards, Daniel & Michael

jimkont commented 9 years ago

Great work Daniel & Michael! Some high level comments (for now).

1) I would rather use the term schema instead of ontology because it can cover other schema types that RDFUnit currently supports (or will support in the future, like shacl).

2) the file paths that are used sometimes cause initialization errors when testing from the IDE (Intellj). Maybe it is better to use the java resource naming directly

instead of Model as input we could use RDFReaders or SchemaSource/TestSource that can more transparently handle java resources.

3) I created an example test based on your code but is not picked up my maven. (although I can run it from Intellj when I set the relative paths correctly).

@RunWith(RdfUnitJunitRunner.class)
@Ontology(uri = Constants.FOAF_ONTOLOGY_URI)
public class ExampleRDFUnitRunner {

        @InputModel
        public Model getInputData() {
            return ModelFactory
                    .createDefaultModel()
                    .read("file:src/test/resources/inputmodels/foaf.rdf");
        }
}

4) re-running only failed tests (supported by the IDE) does not work but this is minor

5) we could also allow a list of @InputModel and the runner could create test combinations of schema x InputModel

6) Test descriptions could use some tweaking but I need to deal with some prefix generation related tasks first (e.g. #34 / #39)

overall, I am very happy to accept it as is and iterate over time but I see you made some comments already. Let me know when you are ready to merge

dhiller commented 9 years ago

Think we've addressed most of the issues now.

Regarding the "re-run failed tests" issue, I believe this won't be achievable, though :(

dhiller commented 9 years ago

@jimkont please let us know what you think :)

dhiller commented 9 years ago

BTW regarding the "run-test" issue you mentioned, I use intellij to run the internal test contained in RunnerTest$TestRunner, works fine for me.

jimkont commented 9 years ago

To get rid off hardcoding stuff we should go with an approach similar to

@RunWith(RdfUnitJunitRunner.class)
public class ExampleTest {

    @Schema
    public SchemaSource schemaSource = SchemaSourceFactory.createSchemaSourceSimple("foaf", Constants.FOAF_ONTOLOGY_URI, RDFReaderFactory.createResourceReader(Constants.FOAF_ONTOLOGY_URI));

    @TestInput
    public TestSource testSource = new TestSourceBuilder()
            .setImMemSingle()
            .setInMemReader(RDFReaderFactory.createResourceReader("inputmodels/foaf.rdf"))
            .setReferenceSchemata(schemaSource)
            .build();
}

and we can define some new factory methods to simplify object construction

dhiller commented 9 years ago

@jimkont Regarding your SchemaSource change proposal, we can't see how this would help as we need the RDFReader for test generation which is not exposed by the SchemaSource.

Aside from the initialization error handling (which could be improved) we would propose to rather merge this pull request to prepare for a release as it covers our current use cases. We would then create an issue pulling together the remaining improvements and get back when we can spend the time again.

Would that be ok for you?

jimkont commented 9 years ago

more than happy. do you want me to make a new release?

dhiller commented 9 years ago

We'd be glad if you could release this :)

jimkont commented 9 years ago

Thanks again for the amazing work! the release is ready Also note that rdfunit is now in maven central http://search.maven.org/#artifactdetails|org.aksw.rdfunit|rdfunit-junit|0.7.19|