Unit Testing

ChaiJ - JUnit integration

com.github.adowrath : chaiJ-junit

ChaiJ is a Java assertion library in the expect-style.

Last Version: 0.2.0

Release Date:

Last Version: 0.3.0

Release Date:

Generic Testing Framework

io.github.seniortesting : sparrow-junit-parent

This library is a rich test framework for unittest, service test, UI test.etc.

Last Version: 1.0.3

Release Date:

Last Version: 1.1.0

Release Date:

struts2-junit

com.hexaid.struts2.junit : struts2-junit

Struts 2 utility library to perform integration testing with JUnit 4

Last Version: 0.2.2

Release Date:

Testing utilities: MySQL Junit 5 Framework

com.torodb.testing : mysql-junit-5

This is a aggregation and parent pom used by ToroDB testing utility projects.

Last Version: 1.0.0

Release Date:

Last Version: 0.4.4

Release Date:

Last Version: 7.1.1

Release Date:

junit-xml-plugin

io.qameta.allure.plugins : junit-xml-plugin

Module junit-xml-plugin of Allure Framework.

Last Version: 2.18.1

Release Date:

Selenide JUnit5 simple example project

org.selenide : selenide-junit5-archetype

This archetype generates a sample Selenide (http://selenide.org) project

Last Version: 0.9.3

Release Date:

Last Version: 1.2.1

Release Date:

junit-playwright

io.github.uchagani : junit-playwright

junit-playwright allows you to easily run Playwright-Java tests in parallel

Last Version: 2.2.5

Release Date:

Example JUnit4 Guice Integration Test

org.testifyproject.examples : example-junit-guice-integrationtest

Creates a new quickstart project to integration test Guice modules and services with Testify, JUnit4, Mockito, and AssertJ.

Last Version: 1.0.0

Release Date:

Last Version: 0.811.2

Release Date:

junit4-examples

com.github.noconnor : junit4-examples

API performance testing framework built using JUnit

Last Version: 1.21.0

Release Date:

integration-test-junit4

io.toolisticon.compiletesting : integration-test-junit4

Please refer to https://github.com/toolisticon/compile-testing

Last Version: 0.8.0

Release Date:

JUnitInstrumentationTestRunner

de.felixschulze.android.test : JUnitInstrumentationTestRunner

JUnitInstrumentationTestRunner is a extension for the Android InstrumentationTestRunner which adds the JUnitTestListener for writing test-results into an XML file.

Last Version: 1.0

Release Date:

JUnit characterization test utility

pl.marchwicki : junit-characterization

Tiny utility library which leverages JUnit @Rules in order to build and run characterization tests for legacy applications

Last Version: 0.3

Release Date:

Last Version: 0.12.0

Release Date:

webtau-junit5-examples

org.testingisdocumenting.webtau : webtau-junit5-examples

WebTau - web test automation. REST/GraphQL/DB/CLI/UI testing framework.

Last Version: 1.48

Release Date:

Last Version: 1.0.9

Release Date:

webtau-junit4-examples

com.twosigma.webtau : webtau-junit4-examples

webtau - web test automation. REST and UI testing framework.

Last Version: 1.20

Release Date:

autojunit-plugin

com.github.onlypiglet : autojunit-plugin

a project about auto gen junit source

Last Version: 1.0.1-alpha

Release Date:

Orangebeard.io JUnit5 Listener

io.orangebeard : junit5-listener

Send JUnit5 test results to an Orangebeard.io instance

Last Version: 1.0.14

Release Date:

Last Version: 2.0.0-alpha05

Release Date:

JUnit 5 WireMock Extension

io.github.ricall.junit5-wiremock : junit5-wiremock

A JUnit 5 extension library that allows you to run WireMockServer in your JUnit tests. Operates in a similar fashion to the JUnit4 WireMockRule @Rule classes that ship with Wiremock.

Last Version: 2.0.0

Release Date:

lsd-junit5

com.github.nickmcdowall : lsd-junit5

A library providing a Junit5 extension for generating LSD reports

Last Version: 0.1.0

Release Date:

junit-platform-otel-auto

com.ryandens : junit-platform-otel-auto

Module which auto-registers the com.ryandens:junit-platform-otel-api modules with the JUnit Engine and uses the OpenTelemetry auto-configured SDK for tracing.

Last Version: 0.1.0

Release Date:

JUnitRunner Parent project

com.github.junitrunner : junitrunner-parent

The extension friendly JUnit Runner with support for plugins ann implementations of Plugins for some popular frameworks

Last Version: 0.0.2

Release Date:

eu.coldrye.junit:file-assertions

eu.coldrye.junit : file-assertions

Assertions dealing explicitly with files and their content

Last Version: 1.0.0

Release Date:

Last Version: 1.0.0-M5

Release Date:

bot-junit5

com.github.dreamhead : bot-junit5

Object bot is a library for setting up Java objects as test data.

Last Version: 1.0.0

Release Date:

lockss-junit4-bundle

org.lockss : lockss-junit4-bundle

POM bundle for LOCKSS projects using JUnit 4

Last Version: 1.5.0

Release Date:

junitXmlFormatter

io.github.barrypitman : junit-xml-formatter

Contains a JUnit RunListener for generating JUnit XML reports

Last Version: 1.3

Release Date:

AssertJ-Swing - JUnit 4.5 Extension

org.assertj : assertj-swing-junit-4.5

JUnit 4.5-specific extension for AssertJ-Swing

Last Version: 1.2.0

Release Date:

assertj-jaxrs-junit-jupiter

com.github.attiand : assertj-jaxrs-junit-jupiter

Provides assertj assertions to jaxrs responses

Last Version: 2.0.0

Release Date:

Last Version: 1.5.1

Release Date:

Last Version: 0.1.0

Release Date:

js2junit

com.github.weaselflink : js2junit

Perform unit-tests of Javascript inside JUnit.

Last Version: 1.2

Release Date:

pact-jvm-provider-junit_2.10

au.com.dius : pact-jvm-provider-junit_2.10

# Pact junit runner ## Overview Library provides ability to play contract tests against a provider service in JUnit fashionable way. Supports: - Out-of-the-box convenient ways to load pacts - Easy way to change assertion strategy - **org.junit.BeforeClass**, **org.junit.AfterClass** and **org.junit.ClassRule** JUnit annotations, that will be run once - before/after whole contract test suite. - **org.junit.Before**, **org.junit.After** and **org.junit.Rule** JUnit annotations, that will be run before/after each test of an interaction. - **au.com.dius.pact.provider.junit.State** custom annotation - before each interaction that requires a state change, all methods annotated by `@State` with appropriate the state listed will be invoked. ## Example of HTTP test ```java @RunWith(PactRunner.class) // Say JUnit to run tests with custom Runner @Provider("myAwesomeService") // Set up name of tested provider @PactFolder("pacts") // Point where to find pacts (See also section Pacts source in documentation) public class ContractTest { // NOTE: this is just an example of embedded service that listens to requests, you should start here real service @ClassRule //Rule will be applied once: before/after whole contract test suite public static final ClientDriverRule embeddedService = new ClientDriverRule(8332); @BeforeClass //Method will be run once: before whole contract test suite public static void setUpService() { //Run DB, create schema //Run service //... } @Before //Method will be run before each test of interaction public void before() { // Rest data // Mock dependent service responses // ... embeddedService.addExpectation( onRequestTo("/data"), giveEmptyResponse() ); } @State("default", "no-data") // Method will be run before testing interactions that require "default" or "no-data" state public void toDefaultState() { // Prepare service before interaction that require "default" state // ... System.out.println("Now service in default state"); } @TestTarget // Annotation denotes Target that will be used for tests public final Target target = new HttpTarget(8332); // Out-of-the-box implementation of Target (for more information take a look at Test Target section) } ``` ## Example of AMQP Message test ```java @RunWith(PactRunner.class) // Say JUnit to run tests with custom Runner @Provider("myAwesomeService") // Set up name of tested provider @PactBroker(host="pactbroker", port = "80") public class ConfirmationKafkaContractTest { @TestTarget // Annotation denotes Target that will be used for tests public final Target target = new AmqpTarget(); // Out-of-the-box implementation of Target (for more information take a look at Test Target section) @BeforeClass //Method will be run once: before whole contract test suite public static void setUpService() { //Run DB, create schema //Run service //... } @Before //Method will be run before each test of interaction public void before() { // Message data preparation // ... } @PactVerifyProvider('an order confirmation message') String verifyMessageForOrder() { Order order = new Order() order.setId(10000004) order.setPrice(BigDecimal.TEN) order.setUnits(15) def message = new ConfirmationKafkaMessageBuilder() .withOrder(order) .build() JsonOutput.toJson(message) } } ``` ## Pact source The Pact runner will automatically collect pacts based on annotations on the test class. For this purpose there are 3 out-of-the-box options (files from a directory, files from a set of URLs or a pact broker) or you can easily add your own Pact source. **Note:** You can only define one source of pacts per test class. ### Download pacts from a pact-broker To use pacts from a Pact Broker, annotate the test class with `@PactBroker(host="host.of.pact.broker.com", port = "80")`. From _version 3.2.2/2.4.3+_ you can also specify the protocol, which defaults to "http". The pact broker will be queried for all pacts with the same name as the provider annotation. For example, test all pacts for the "Activity Service" in the pact broker: ```java @RunWith(PactRunner.class) @Provider("Activity Service") @PactBroker(host = "localhost", port = "80") public class PactJUnitTest { @TestTarget public final Target target = new HttpTarget(5050); } ``` #### _Version 3.2.3/2.4.4+_ - Using Java System properties The pact broker loader was updated to allow system properties to be used for the hostname, port or protocol. The port was changed to a string to allow expressions to be set. To use a system property or environment variable, you can place the property name in `${}` expression de-markers: ```java @PactBroker(host="${pactbroker.hostname}", port = "80") ``` You can provide a default value by separating the property name with a colon (`:`): ```java @PactBroker(host="${pactbroker.hostname:localhost}", port = "80") ``` #### _Version ???/???+_ - More Java System properties The default values of the `@PactBroker` annotation now enable variable interpolation. The following keys may be managed through the environment * `pactbroker.host` * `pactbroker.port` * `pactbroker.protocol` * `pactbroker.tags` (comma separated) * `pactbroker.auth.scheme` * `pactbroker.auth.username` * `pactbroker.auth.password` #### _Version 3.2.4/2.4.6+_ - Using tags with the pact broker The pact broker allows different versions to be tagged. To load all the pacts: ```java @PactBroker(host="pactbroker", port = "80", tags = {"latest", "dev", "prod"}) ``` The default value for tags is `latest` which is not actually a tag but instead corresponds to the latest version ignoring the tags. If there are multiple consumers matching the name specified in the provider annotation then the latest pact for each of the consumers is loaded. For any other value the latest pact tagged with the specified tag is loaded. Specifying multiple tags is an OR operation. For example if you specify `tags = {"dev", "prod"}` then both the latest pact file tagged with `dev` and the latest pact file taggged with `prod` is loaded. #### _Version 3.3.4/2.4.19+_ - Using basic auth with the with the pact broker You can use basic authentication with the `@PactBroker` annotation by setting the `authentication` value to a `@PactBrokerAuth` annotation. For example: ```java @PactBroker(host = "${pactbroker.url:localhost}", port = "1234", tags = {"latest", "prod", "dev"}, authentication = @PactBrokerAuth(username = "test", password = "test")) ``` The `username` and `password` values also take Java system property expressions. ### Pact Url To use pacts from urls annotate the test class with ```java @PactUrl(urls = {"http://build.server/zoo_app-animal_service.json"} ) ``` ### Pact folder To use pacts from a resource folder of the project annotate test class with ```java @PactFolder("subfolder/in/resource/directory") ``` ### Custom pacts source It's possible to use a custom Pact source. For this, implement interface `au.com.dius.pact.provider.junit.loader.PactLoader` and annotate the test class with `@PactSource(MyOwnPactLoader.class)`. **Note:** class `MyOwnPactLoader` must have a default empty constructor or a constructor with one argument of class `Class` which at runtime will be the test class so you can get custom annotations of test class. ## Test target The field in test class of type `au.com.dius.pact.provider.junit.target.Target` annotated with `au.com.dius.pact.provider.junit.target.TestTarget` will be used for actual Interaction execution and asserting of contract. **Note:** there must be exactly 1 such field, otherwise an `InitializationException` will be thrown. ### HttpTarget `au.com.dius.pact.provider.junit.target.HttpTarget` - out-of-the-box implementation of `au.com.dius.pact.provider.junit.target.Target` that will play pacts as http request and assert response from service by matching rules from pact. _Version 3.2.2/2.4.3+_ you can also specify the protocol, defaults to "http". ### AmqpTarget `au.com.dius.pact.provider.junit.target.AmqpTarget` - out-of-the-box implementation of `au.com.dius.pact.provider.junit.target.Target` that will play pacts as an AMQP message and assert response from service by matching rules from pact. #### Modifying the requests before they are sent [Version 3.2.3/2.4.5+] Sometimes you may need to add things to the requests that can't be persisted in a pact file. Examples of these would be authentication tokens, which have a small life span. The HttpTarget supports request filters by annotating methods on the test class with `@TargetRequestFilter`. These methods must be public void methods that take a single HttpRequest parameter. For example: ```java @TargetRequestFilter public void exampleRequestFilter(HttpRequest request) { request.addHeader("Authorization", "OAUTH hdsagasjhgdjashgdah..."); } ``` __*Important Note:*__ You should only use this feature for things that can not be persisted in the pact file. By modifying the request, you are potentially modifying the contract from the consumer tests! #### Turning off URL decoding of the paths in the pact file [version 3.3.3+] By default the paths loaded from the pact file will be decoded before the request is sent to the provider. To turn this behaviour off, set the system property `pact.verifier.disableUrlPathDecoding` to `true`. __*Important Note:*__ If you turn off the url path decoding, you need to ensure that the paths in the pact files are correctly encoded. The verifier will not be able to make a request with an invalid encoded path. ### Custom Test Target It's possible to use custom `Target`, for that interface `Target` should be implemented and this class can be used instead of `HttpTarget`. # Verification Reports [versions 3.2.7/2.4.9+] The default test behaviour is to display the verification being done to the console, and pass or fail the test via the normal JUnit mechanism. From versions 3.2.7/2.4.9+, additional reports can be generated from the tests. ## Enabling additional reports via annotations on the test classes A `@VerificationReports` annotation can be added to any pact test class which will control the verification output. The annotation takes a list report types and an optional report directory (defaults to "target/pact/reports"). The currently supported report types are `console`, `markdown` and `json`. For example: ```java @VerificationReports({"console", "markdown"}) public class MyPactTest { ``` will enable the markdown report in addition to the normal console output. And, ```java @VerificationReports(value = {"markdown"}, reportDir = "/myreports") public class MyPactTest { ``` will disable the normal console output and write the markdown reports to "/myreports". ## Enabling additional reports via Java system properties or environment variables The additional reports can also be enabled with Java System properties or environment variables. The following two properties have been introduced: `pact.verification.reports` and `pact.verification.reportDir`. `pact.verification.reports` is the comma separated list of report types to enable (e.g. `console,json,markdown`). `pact.verification.reportDir` is the directory to write reports to (defaults to "target/pact/reports"). ## Additional Reports The following report types are available in addition to console output (`console`, which is enabled by default): `markdown`, `json`. You can also provide a fully qualified classname as report so custom reports are also supported. This class must implement `au.com.dius.pact.provider.reporters.VerifierReporter` interface in order to be correct custom implementation of a report.

Last Version: 2.4.20

Release Date:

Last Version: 1.10.1.0.0

Release Date:

quick-perf-junit4-parent

org.quickperf : quick-perf-junit4-parent

QuickPerf is a testing library for Java providing annotations to quickly evaluate some performance properties.

Last Version: 1.1.0

Release Date:

Last Version: 0.4.5

Release Date:

Tomcat Mock Server

com.dthoffman.tomcatmock : junit-example

Helper code to spin up a tomcat app during tests and mocking downstream http calls

Last Version: 0.0.1

Release Date: