Skip to content

ikysil/cdi-unit

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cdi-unit

Unit testing for CDI applications. Supports Mockito for mocking dependencies.

See website for full details http://cdi-unit.github.io/cdi-unit

Discussion can be found here https://groups.google.com/forum/#!forum/cdi-unit

Maven Central javadoc

Getting the latest release

CDI-Unit 5

  • Supports CDI 3.x+ (jakarta. packages)
  • Requires Java 11

CDI-Unit 4

  • Supports CDI 1.x or 2.x (javax. packages)
  • Supports Java 8 and Java 11

Only one major version is supported at a time, and changes are not backported to older versions.

<dependency>
  <groupId>io.github.cdi-unit</groupId>
  <artifactId>cdi-unit</artifactId>
  <version>${cdi-unit-version}</version>
  <scope>test</scope>
</dependency>

Example unit test

class Starship {

  @Inject
  Engine engine; //We don't know the exact engine that this ship will have.

  void start() {
    engine.start();
  }
}

@RunWith(CdiRunner.class)
@AdditionalClasses(WarpDrive.class) // WarpDrive is available to use.
class TestStarship {

  @Inject
  Starship starship;

  @Test
  public void testStart() {
    starship.start(); // Going to warp!
  }
}

Acknowledgements

This project uses code shamelessly copied from:

Mockrunner under Apache license. Resteasy under Apache license.

License

Copyright 2013 CDI-Unit contributors.

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.

About

Unit testing for CDI applications

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 92.2%
  • Groovy 7.0%
  • Other 0.8%