Fixture Framework to inject Testdata with CDI. You can define multiple configurators with different data for each entity.
- Checkout the repository
- run
mvn clean install
- add the following dependency to your project
<dependency>
<groupId>ch.dvbern.oss.cdifixtures</groupId>
<artifactId>cdi-fixtures</artifactId>
<version>(NEWEST_VERSION)</version>
</dependency>
- Create a Configurator
The configurator needs to implement the interface ch.dvbern.lib.cdi-fixtures.Configurator. In the configure()-method you can define the data needed for this specific configuration.
- Use it in Test
@Inject
@ConfiguratorClass(CustomerConfigurator.class)
@Persisted
private Instance<FixtureObject<Customer>> customerFixtureObject;
...
Customer testCustomer = customerFixtureObject.get().get();
- Persisted vs. NonPersisted
Use the @Persisted
Annotation if your entity should be persisted before your Test starts, or @NonPersisted
if you
want to persist it in your Testcode.
- Maven - Dependency Management
Please read CONTRIBUTING.md for the process for submitting pull requests to us.
One healthy social atmospehere is very important to us, wherefore we rate our Code of Conduct high. For details check the file CODE_OF_CONDUCT.md
- DV Bern AG - Initial work - dvbern
See also the list of contributors who participated in this project.
This project is licensed under the Apache 2.0 License - see the License.md file for details.