All Projects → guhilling → cdi-test

guhilling / cdi-test

Licence: Apache-2.0 license
JUnit extension for easy and efficient testing of CDI components

Programming Languages

java
68154 projects - #9 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to cdi-test

javaee8-cookbook
Jakarta EE 8 Cookbook (second edition)
Stars: ✭ 40 (+73.91%)
Mutual labels:  cdi, javaee8
migrate-Java-EE-app-to-azure
Migrate an existing Java EE workload to Azure
Stars: ✭ 12 (-47.83%)
Mutual labels:  cdi, javaee8
Javaee7 Samples
Java EE 7 Samples
Stars: ✭ 2,470 (+10639.13%)
Mutual labels:  junit, cdi
jpa-unit
JUnit extension to test javax.persistence entities
Stars: ✭ 28 (+21.74%)
Mutual labels:  junit, cdi
Mastering Junit5
A comprehensive collection of test examples created with JUnit 5
Stars: ✭ 223 (+869.57%)
Mutual labels:  junit
Vscode Java Test
Run and debug Java test cases in Visual Studio Code.
Stars: ✭ 177 (+669.57%)
Mutual labels:  junit
Testowanieoprogramowania
Testowanie oprogramowania - Książka dla początkujących testerów
Stars: ✭ 146 (+534.78%)
Mutual labels:  junit
Java Ddd Skeleton
♨️ DDD in Java skeleton & examples. Course:
Stars: ✭ 140 (+508.7%)
Mutual labels:  junit
junit.testlogger
JUnit test logger for vstest platform
Stars: ✭ 61 (+165.22%)
Mutual labels:  junit
Quickperf
QuickPerf is a testing library for Java to quickly evaluate and improve some performance-related properties
Stars: ✭ 231 (+904.35%)
Mutual labels:  junit
Fastlane Plugin Test center
🎯 The best fastlane plugin to understand and tame misbehaving iOS tests 🎉
Stars: ✭ 214 (+830.43%)
Mutual labels:  junit
Video Recorder Java
This library allows easily record video of your UI tests by just putting couple annotations.
Stars: ✭ 179 (+678.26%)
Mutual labels:  junit
Androidunittest
Save time & clear your unit tests on Android !
Stars: ✭ 205 (+791.3%)
Mutual labels:  junit
Expekt
BDD assertion library for Kotlin
Stars: ✭ 163 (+608.7%)
Mutual labels:  junit
Spring Boot Testing Strategies
Sample project demonstrating different Test Strategies that can be followed when using Spring Boot.
Stars: ✭ 233 (+913.04%)
Mutual labels:  junit
Spectrum
A BDD-style test runner for Java 8. Inspired by Jasmine, RSpec, and Cucumber.
Stars: ✭ 142 (+517.39%)
Mutual labels:  junit
Junit Dataprovider
A TestNG like dataprovider runner for JUnit with many additional features
Stars: ✭ 226 (+882.61%)
Mutual labels:  junit
Reporting
Zebrunner Reporting Tool
Stars: ✭ 198 (+760.87%)
Mutual labels:  junit
Bats Core
Bash Automated Testing System
Stars: ✭ 2,820 (+12160.87%)
Mutual labels:  junit
Tutorial
Spring Boot的例子,包含RESTful API, MVC, JMS, Cache, Mybatis, Cache, Websocket...
Stars: ✭ 215 (+834.78%)
Mutual labels:  junit

Build CDI Test CodeQL Coverage (Sonar) Status (Sonar) Maintainability (Sonar) Maven Central

cdi-test: A JUnit extension for easy and efficient testing of CDI components

cdi-test is available under the The Apache Software License, Version 2.0

Why should you use it?

If you're developing Jakarta EE (Java EE) or just plain CDI applications or libraries you'll probably want to unit test your code. If you don't you really should. With cdi-test there's no excuse not to do it ;-)

As CDI doesn't come with any "standard" unit test capabilities you need some way to test your components in your JUnit 5 tests. This is not easily accomplished especially when compared with the junit integration of Spring Boot.

Highlights

cdi-test is targeted at running unit, component and integration tests at scale. It accomplishes this with:

  • Only booting the cdi container once for all unit tests. This allows for running a huge number of tests even in big projects where booting might take some time.
  • cdi-test uses Weld (the cdi reference implementation) as cdi container. So you can use the exact same cdi container as in your application runtime in case you're running e.g. Wildfly, JBoss EAP, GlassFish or Oracle WebLogic.
  • cdi-test supports mocks and test alternatives for CDI beans. These can be activated per test class. So you can freely choose what you want to test and need to mock test-by-test.
  • Well tested and maintained and used in real projects with thousands of unit tests.

Compatibility

  • CDI 2 and CDI 3 with the relevant releases of Weld
  • Java 8+
  • Jakarta EE 8 and Jakarta EE 9 (The new namespace introduced with Jakarta EE 9 will be supported starting with release 4.x. Pre-releases are already available.)
    • Includes using EJBs with some restrictions. Injection and creation of @Stateful and @Stateless ejbs.
    • Supports JPA even with multiple persistence units. Inject EntityManager via @Inject or @PersistenceContext.
  • JUnit 5 (starting with cdi-test 3.x)
  • Microprofile Config 2.x and 3.x
    • Supports injecting test specific properties using annotations.
  • Mockito is supported and used internally.

Short example, please!

Most basic:

@ExtendWith(CdiTestJunitExtension.class)
class SimpleTest {
@Inject
private Person person;
@Test
void testInjection() {
assertNotNull(person);
}
}

Using mocks:

@ExtendWith(CdiTestJunitExtension.class)
@ExtendWith(MockitoExtension.class)
class MockProxyTest {
@Inject
private SampleService sampleService;
@Test
void createPersonWithMockBackend(@Mock BackendService backendService) {
Person person = new Person();
sampleService.storePerson(person);
verify(backendService).storePerson(person);
}
}

In-depth Documentation

See the Documentation on github pages.

Contributing

Contribution guidelines for this project

LICENSE

Copyright 2015 Gunnar Hilling

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Sponsors

JProfiler supports open source projects with its full-featured Java Profiler. Click the JProfiler logo below to learn more.

JProfiler JetBrains Logo
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].