Difference between revisions of "JUnit"

From NovaOrdis Knowledge Base
Jump to: navigation, search
(JUnit and Gradle)
(Concepts)
Line 49: Line 49:
 
* [[@RunWith]]
 
* [[@RunWith]]
 
* [[@BeforeClass]]/[[@AfterClass]]
 
* [[@BeforeClass]]/[[@AfterClass]]
 +
 +
=Patterns=
 +
 +
* [[JUnit assertThrows()]]

Revision as of 22:30, 8 November 2019

External

Internal

Overview

Dependencies

dependencies {
    testImplementation "junit:junit:4.12"
}

JUnit and Gradle

The only configuration required to enable unit testing in a Gradle project is to apply the Java plugin and declared JUnit as testImplementation:

apply plugin: 'java'

repositories {
    mavenCentral()
}

dependencies {
    ...
    testImplementation "junit:junit:4.12"
}

This will allow to declare @Test methods and will enable result parsing to generate HTML reports.

Passing System Properties to Tests

See:
Gradle Java Plugin - Passing System Properties to Tests

Concepts

Test Runner

A JUnit plugin that provides custom testing behavior. Specified with @RunWith.

Annotations

Patterns