Coder Social home page Coder Social logo

junit-integration-test's Introduction

Build Status

JUnit integration test example

JUnit is a great test framework. At most of the time is used for unit test. While it can also be used for integration test.

Unit Test

  • is a software testing method
  • test a piece of code
  • methods as interfaces
  • does not install the software being developed
  • mocks can be used to isolate external dependencies

Integration Test

  • is a software testing method
  • test the software. The software is called SUT (System Under Test)
  • the whole software is a black box
  • the software usually need be installed
  • mocks can be used to isolate external dependencies

A maven example project for integration test framework.

In this case, the project is a test project. All code are used for testing. While we can split the testing into two parts.

  • integration test
  • unit test the integration test

suporting function for integration test

Some functions will be needed to support intetration test. The following parts are most common functions needed for integration test.

  • interface module which connect to the SUT (System Under Test), REST, WebService, SSH
  • authentication in order to connect to the SUT.
  • data collection

unit test the testing

All unit tests are located at directory src/test.

Surefire plugin has great support for unit test.

Default junit pattern for file are

  • **/Test.java
  • ***/*Test.java
  • ***/*TestCase.java

Execute unit test with following command

	mvn test

In the example the following two test cases will be run

	class TestUnit1
	class TestUnit2

The report will be located at

	${basedir}/target/surefire-reports

Execute only specified class

    mvn test -Dtest=TestUnit1

Execute only specified method in a class

    mvn test -Dtest=TestUnit1#testUnit1Success

Execute with specified test class with regex

    mvn test -Dtest=TestUnit*

Execute with specified test class and method with regex

    mvn test -Dtest=TestUnit*#test*

Execute with multiple specified test class and method

    mvn test -Dtest=TestUnit1#testUnit1Fail,TestUnit2#unit2

Execute with multiple specified test class and method with regex

    mvn test -Dtest=TestUnit*#*Fail,TestUnit2*#test*

integration test

All integration test are located at directory src/test

Failsafe plugin has great support for integration test.

Default junit pattern for file are

  • **/IT.java
  • ***/*IT.java
  • ***/*ITCase.java

Execute integration test with following command.

	mvn verify

Execute only integration test by ignore unit test with following command.

	mvn verify -Dskip.surefire.tests

In the example the following two test cases will be run

	class TestUnit1
	class TestUnit2

The report will be located at

	${basedir}/target/failsafe-reports

smoke integration

Default junit pattern for file are

  • **/ITSmoke.java

Execute integration test with following command.

	mvn verify -P smoke

Execute only integration test by ignore unit test with following command.

	mvn verify -P smoke -Dskip.surefire.tests

nightly integration

Default junit pattern for file are

  • **/ITNightly.java

Execute integration test with following command.

	mvn verify -P nightly

Execute only integration test by ignore unit test with following command.

	mvn verify -P nightly -Dskip.surefire.tests

weekly integration test

Default junit pattern for file are

  • **/ITWeekly.java

Execute integration test with following command.

	mvn verify -P weekly

Execute only integration test by ignore unit test with following command.

	mvn verify -P weekly -Dskip.surefire.tests

junit-integration-test's People

Contributors

rockie-yang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.