Migrate to JUnit6#681
Conversation
Internally, we'll use a new class `SolverBasedTest` (without the `0` at the end) for testing with JUnit6. The new class won't be included in the *.jar and is not part of the official API for now
# Conflicts: # src/org/sosy_lab/java_smt/test/SMTLibTokenizerTest.java
| Keep this file synchronized with | ||
| https://gitlab.com/sosy-lab/software/java-project-template | ||
| --> | ||
| <settings defaultResolver="Sosy-Lab"/> | ||
| <settings defaultResolver="default"/> | ||
| <property name="repo.dir" value="${basedir}/repository"/> | ||
| <resolvers> | ||
| <!-- Resolver for downloading dependencies --> | ||
| <url name="Sosy-Lab" descriptor="required"> | ||
| <ivy pattern="${ivy.repo.url}/[organisation]/[module]/ivy-[revision].xml" /> | ||
| <artifact pattern="${ivy.repo.url}/[organisation]/[module]/([arch]/)[artifact]-[revision](-[classifier]).[ext]" /> | ||
| </url> | ||
| <chain name="default"> | ||
| <!-- Download packages from Sosy-Labs --> | ||
| <url name="Sosy-Lab" descriptor="required"> | ||
| <ivy pattern="${ivy.repo.url}/[organisation]/[module]/ivy-[revision].xml"/> | ||
| <artifact pattern="${ivy.repo.url}/[organisation]/[module]/([arch]/)[artifact]-[revision](-[classifier]).[ext]"/> | ||
| </url> | ||
| <!-- Use Maven central as a fallback --> | ||
| <ibiblio name="central" m2compatible="true"/> | ||
| </chain> | ||
|
|
||
| <!-- Resolver for publishing this project --> | ||
| <filesystem name="Sosy-Lab-Publish"> |
There was a problem hiding this comment.
Can be reverted once we have ant-junitlauncher from org.apache.ant in Ivy
For the projects where I am maintainer of I would not want to give up
I think having skipped tests visible in the report is valuable. Otherwise one has no chance of detecting unexpectedly skipped tests.
This seems also pretty inconvenient. So we have several disadvantages and to me JUnit 5+ does not seem worth it. Or are there any advantages that would outweigh this? |
…est to only iterate over enabled solvers
Adding @disabled no longer seems to prevent the test runner from picking up these classes, and they wind up with "UNKNOWN" tests in the results
|
Hello Philipp
I've now included the
These are really both issues with the legacy/Junit4 xml format that we use to generate test reports. I've now switched the branch to the new opentest format, which should support all Junit5 features and prints all the information that was missing. The CLI tool to generate the reports is still a little rough around the edges, but seems to work fine so far:
You can have a look at a full generated report here
I think Junit5 is more of an evolutionary design with a more modular architecture that is easier to extend. Apart from maybe |
So we can run JUnit 4 tests with JUnit 5+? Are there actually any advantages in writing a JUnit 5+ test then? From the diff of the PR it looks as the changes are just changes, not improvements that make the tests nicer.
The report looks nice, but is this stable enough already that we want to use it? And can we export the test data to GitLab as we did before?
What does |
Yes, at least for now. The
I tried to keep this branch as straight forward as possible. There are some additional changes in junit6-nested where I tried to use
I've tried here and unfortunately GitLab does not seem to recognize the opentest format. However, we could generate additional xml reports in the JUnit4 format for GitLab to get some basic feedback, although the solver names would likely be missing
I think there can only be one runner in JUnit4, so |
For
Well, as I mentioned already, using
Parameterized tests without descriptive names of the parameter values do not seem like a good idea.
Cf. above. I don't really see a nice for using non-static nested classes for tests, seems more confusing than beneficial. If you really want something like that, simply make the static inner class inherit from the outer class, then standard Java semantics that everyone know provide basically what |


Hello,
this PR is a draft for migrating our tests from Junit4 to Junit6. Most of the changes are straight forward substitutions, and I tried to avoid any more substantial changes to our test classes for now : if needed, this can still be handled later in a separate PR. To preserve compatibility with other projects that may use out test classes as a basis, I also avoided changes to
SolverBasedTest0and instead cloned the class. The new versionSolverBasedTest(without the0at the end) uses JUnit6 and is for internal use only, while the older versionSolverBasedTest0(with the0) is still available for other projectsCurrent test results with Junit6 can be found here, and here are the same results with JUnit4 tests for comparison
Some caveats to keep in mind:
PackageSanitytest, which don't appear to be working with JUnit6 and are not picked up by the test runner. However, that still leaves 2 tests unaccounted forSkippedtests are not shown in the JUnit6 results. The reason is that JUnit6 sees theses tests asabortedand notskippedas they were (partially) run before an assumption failed. If this is an issue, and we want to keep skipped tests visible, there should probably be a workaround for thistestGetArrays5d()[5], instead oftestGetArrays5d[Z3], that is, with a parameter index, rather than a parameter value in the[]brackets at the end. The number is "deterministic", so it's possible to figure out which solver is meant by5, and when running the tests in Intellij (and presumably other IDEs) this also isn't a problem and the parameters are properly printed. However, for the HTML report all we get are these numbers, and I wasn't able to find any way to change thatTruthstill depends on it (However, so far this doesn't appear to cause any issues)anton our test systems if we want to use JUnit6. The current version is too old and doesn't support theforkmodeattribute that is needed for out tests. However, it should be enough to just updateant, and not the entire system