diff options
| author | Federico Igne <git@federicoigne.com> | 2021-10-04 09:54:55 +0100 |
|---|---|---|
| committer | Federico Igne <git@federicoigne.com> | 2021-10-04 09:54:55 +0100 |
| commit | 8f6759bfa0cfcfaf379d09c0c331aabb7395d319 (patch) | |
| tree | de0341d9cecd1e11ae35acd0fb666e4c420ec997 | |
| parent | 0d311287610bcf14a1b4ff35008359dde8c00fc3 (diff) | |
| download | RSAComb-8f6759bfa0cfcfaf379d09c0c331aabb7395d319.tar.gz RSAComb-8f6759bfa0cfcfaf379d09c0c331aabb7395d319.zip | |
Tag some tests as slow
| -rw-r--r-- | README.md | 23 | ||||
| -rw-r--r-- | src/test/scala/uk/ac/ox/cs/rsacomb/functional/Functional.scala | 17 |
2 files changed, 37 insertions, 3 deletions
| @@ -118,11 +118,32 @@ java -cp <path/to/JRDFox.jar>:<path/to/fat.jar> uk.ac.ox.cs.rsacomb.RSAComb [<op | |||
| 118 | 118 | ||
| 119 | ### Running tests | 119 | ### Running tests |
| 120 | 120 | ||
| 121 | To run the suit of unit test provided along with the code run | 121 | To run the suites of tests provided along with the code run |
| 122 | ``` | 122 | ``` |
| 123 | sbt test | 123 | sbt test |
| 124 | ``` | 124 | ``` |
| 125 | 125 | ||
| 126 | This will run all [unit tests](https://en.wikipedia.org/wiki/Unit_testing) and [functional tests](https://en.wikipedia.org/wiki/Functional_testing). | ||
| 127 | If you want to limit the scope of the tests and run only a particular suite use | ||
| 128 | ``` | ||
| 129 | sbt "testOnly <test-class>" | ||
| 130 | ``` | ||
| 131 | |||
| 132 | For example, to execute only unit tests concerning the canonical model computation, run | ||
| 133 | ``` | ||
| 134 | sbt "testOnly uk.ac.ox.cs.rsacomb.CanonicalModelSpec" | ||
| 135 | ``` | ||
| 136 | |||
| 137 | or alternatively | ||
| 138 | ``` | ||
| 139 | sbt "testOnly *CanonicalModelSpec" | ||
| 140 | ``` | ||
| 141 | |||
| 142 | To run only functional tests for LUBM, excluding tests tagged as *slow* (that require more resources), run | ||
| 143 | ``` | ||
| 144 | sbt "testOnly *functional.LUBM -- -l org.scalatest.tags.Slow" | ||
| 145 | ``` | ||
| 146 | |||
| 126 | ## Changes introduced | 147 | ## Changes introduced |
| 127 | 148 | ||
| 128 | We tried to implement the system as close as possible to the theoretical description provided in [[1](#references)]. | 149 | We tried to implement the system as close as possible to the theoretical description provided in [[1](#references)]. |
diff --git a/src/test/scala/uk/ac/ox/cs/rsacomb/functional/Functional.scala b/src/test/scala/uk/ac/ox/cs/rsacomb/functional/Functional.scala index e4ea01b..abede60 100644 --- a/src/test/scala/uk/ac/ox/cs/rsacomb/functional/Functional.scala +++ b/src/test/scala/uk/ac/ox/cs/rsacomb/functional/Functional.scala | |||
| @@ -2,6 +2,7 @@ package uk.ac.ox.cs.rsacomb.functional | |||
| 2 | 2 | ||
| 3 | import org.scalatest.funspec.AnyFunSpec | 3 | import org.scalatest.funspec.AnyFunSpec |
| 4 | import org.scalatest.matchers.should.Matchers | 4 | import org.scalatest.matchers.should.Matchers |
| 5 | import org.scalatest.tagobjects.Slow | ||
| 5 | 6 | ||
| 6 | import uk.ac.ox.cs.rsacomb.ontology.Ontology | 7 | import uk.ac.ox.cs.rsacomb.ontology.Ontology |
| 7 | import uk.ac.ox.cs.rsacomb.approximation.Upperbound | 8 | import uk.ac.ox.cs.rsacomb.approximation.Upperbound |
| @@ -27,12 +28,11 @@ class LUBM extends AnyFunSpec with Matchers { | |||
| 27 | private val rsa = ontology approximate toUpperbound | 28 | private val rsa = ontology approximate toUpperbound |
| 28 | 29 | ||
| 29 | /* Queries and results */ | 30 | /* Queries and results */ |
| 30 | private val queries = | ||
| 31 | RDFoxUtil.loadQueriesFromFile(test / "queries.sparql") | ||
| 32 | private val results = ujson.read(os.read(test / "results.json")).arr | 31 | private val results = ujson.read(os.read(test / "results.json")).arr |
| 33 | 32 | ||
| 34 | describe("Ontology size: 1)") { | 33 | describe("Ontology size: 1)") { |
| 35 | 34 | ||
| 35 | val queries = RDFoxUtil.loadQueriesFromFile(test / "queries.sparql") | ||
| 36 | queries foreach { query => | 36 | queries foreach { query => |
| 37 | it(s"Tested Query${query.id}") { | 37 | it(s"Tested Query${query.id}") { |
| 38 | val answers = rsa.ask(query).answers.map(_._2.mkString("\t")) | 38 | val answers = rsa.ask(query).answers.map(_._2.mkString("\t")) |
| @@ -45,5 +45,18 @@ class LUBM extends AnyFunSpec with Matchers { | |||
| 45 | } | 45 | } |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | val slow = RDFoxUtil.loadQueriesFromFile(test / "queries-slow.sparql") | ||
| 49 | slow foreach { query => | ||
| 50 | it(s"Tested Query${query.id}", Slow) { | ||
| 51 | val answers = rsa.ask(query).answers.map(_._2.mkString("\t")) | ||
| 52 | val reference = results | ||
| 53 | .find(_("queryID").num == query.id) | ||
| 54 | .get("answers") | ||
| 55 | .arr | ||
| 56 | .map(_.str) | ||
| 57 | answers should contain theSameElementsAs reference | ||
| 58 | } | ||
| 59 | } | ||
| 60 | |||
| 48 | } | 61 | } |
| 49 | } | 62 | } |
