Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 3 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 (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-10-28T08:27:17.000Z (18 days ago)
- Last Synced: 2024-10-28T10:19:26.643Z (18 days ago)
- Topics: java, junit5, junit5-extension, oop, unit-testing
- Language: Java
- Homepage:
- Size: 86.9 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Classpath Resources as JUnit Params
[![EO principles respected here](https://www.elegantobjects.org/badge.svg)](https://www.elegantobjects.org)
[![DevOps By Rultor.com](http://www.rultor.com/b/objectionary/jucs)](http://www.rultor.com/p/objectionary/jucs)
[![We recommend IntelliJ IDEA](https://www.elegantobjects.org/intellij-idea.svg)](https://www.jetbrains.com/idea/)[![mvn](https://github.com/objectionary/jucs/actions/workflows/mvn.yml/badge.svg)](https://github.com/objectionary/jucs/actions/workflows/mvn.yml)
[![PDD status](http://www.0pdd.com/svg?name=objectionary/jucs)](http://www.0pdd.com/p?name=objectionary/jucs)
[![Maven Central](https://img.shields.io/maven-central/v/org.eolang/jucs.svg)](https://maven-badges.herokuapp.com/maven-central/org.eolang/jucs)
[![Javadoc](http://www.javadoc.io/badge/org.eolang/jucs.svg)](http://www.javadoc.io/doc/org.eolang/jucs)
[![codecov](https://codecov.io/gh/objectionary/jucs/branch/master/graph/badge.svg)](https://codecov.io/gh/objectionary/jucs)
[![Hits-of-Code](https://hitsofcode.com/github/objectionary/jucs)](https://hitsofcode.com/view/github/objectionary/jucs)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](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