https://github.com/objectionary/jucs
JUnit Classpath Sources: a simple framework for using classpath resources as JUnit sources
https://github.com/objectionary/jucs
java junit5 junit5-extension oop unit-testing
Last synced: 9 days ago
JSON representation
JUnit Classpath Sources: a simple framework for using classpath resources as JUnit sources
- Host: GitHub
- URL: https://github.com/objectionary/jucs
- Owner: objectionary
- License: mit
- Created: 2022-12-05T11:08:14.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-03-17T12:09:16.000Z (about 2 months ago)
- Last Synced: 2025-04-06T16:53:19.511Z (about 1 month ago)
- Topics: java, junit5, junit5-extension, oop, unit-testing
- Language: Java
- Homepage:
- Size: 144 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Classpath Resources as JUnit Params
[](https://www.elegantobjects.org)
[](https://www.rultor.com/p/objectionary/jucs)
[](https://www.jetbrains.com/idea/)[](https://github.com/objectionary/jucs/actions/workflows/mvn.yml)
[](https://www.0pdd.com/p?name=objectionary/jucs)
[](https://maven-badges.herokuapp.com/maven-central/org.eolang/jucs)
[](https://www.javadoc.io/doc/org.eolang/jucs)
[](https://codecov.io/gh/objectionary/jucs)
[](https://hitsofcode.com/view/github/objectionary/jucs)
[](https://github.com/objectionary/jucs/blob/master/LICENSE.txt)There is a simple [`@ClasspathSource`][annotation]
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`:
```xml
org.eolang
jucs
0.2.0```
Then, to iterate over the `*.yaml` files in
the `src/test/resources/org/example/`
directory (assuming you use Maven or Gradle):```java
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](https://github.com/objectionary/eo) repository.## How to Contribute
Fork repository, make changes, send us a
[pull request](https://www.yegor256.com/2014/04/15/github-guidelines.html).
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:```bash
mvn clean install -Pqulice
```You will need Maven 3.3+ and Java 8+.
[annotation]: https://www.javadoc.io/doc/org.eolang/jucs/latest/org/eolang/jucs/ClasspathSource.html