There is a simple @ClasspathSource
annotation in this package. It may help you
turn files, which are available in classpath, into
sources of a JUnit5 test method.
First, add this to your pom.xml
:
<dependency>
<groupId>org.eolang</groupId>
<artifactId>jucs</artifactId>
<version>0.2.0</version>
</dependency>
Then, to iterate over the *.yaml
files in
the src/test/resources/org/example/
directory (assuming you use Maven or Gradle):
import org.eolang.jucs.ClasspathSource;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
final class SimpleTest {
@ParameterizedTest
@ClasspathSource(value="/org/example", glob="**.yaml")
void simpleTest(String yaml) {
// In the "yaml" variable is the content of the YAML file
}
}
The simpleTest()
method will be called a number of times, every time
getting the content of the next YAML file inside the yaml
variable.
We use this library in PacksTest
, OptimizeMojoTest
and SnippetsTest
in the objectionary/eo repository.
Fork repository, make changes, send us a
pull request.
We will review your changes and apply them to the master
branch shortly,
provided they don't violate our quality standards. To avoid frustration,
before sending us your pull request please run full Maven build:
mvn clean install -Pqulice
You will need Maven 3.3+ and Java 8+.