# JUnit enhetstestning

Nivå: intermediate | Målgrupp: Java programmerare | Förkunskaper: Stor erfarenhet av att skriva Java kod
https://www.ribomation.se/programmerings-kurser/junit/

Denna kurs vänder sig till Java utvecklare som ska börja eller precis börjat i ett Java projekt som använder sig av
enhetstestning med JUnit och önskar snabbt bli produktiv.

Enhetstestning (unit testing) är idag en förutsättning för att upprätthålla hög programkods-kvalitet. Du får lära dig om
JUnit version 5, AssertJ assertions, hur man använder mock-objects och mycket mera under denna fullmatade kursdag.

Denna kurs vänder sig till Java utvecklare som ska börja eller precis börjat i ett Java projekt som använder sig av
enhetstestning med JUnit och önskar snabbt bli produktiv.

- The principles of device testing
- The principles of test-driven-development (TDD)
- JUnit version 5
- Test method annotations
- Assertions and matches
- Use of AssertJ assertions
- Repeated tests
- Parameterized tests
- Parallel execution of test
- Dynamically generated tests
- Conditionally performed tests
- The principle of mock objects and the use of Mockito
- JUnit with construction tools such as Maven and Gradle
- Other frameworks based on JUnit

#### Unit Testing and Test-Driven Development
- Background of JUnit
- What is a unit test
- What is an integration test
- What other form of tests are there
- What is TDD (Test-Driven Development)
- Installation of JUnit

#### Basic JUnit Usage
* Installation of JUnit
* Test methods
* Test method annotations
* Using test assertions
* Using display names
* Running inside IntelliJ (or your favorite IDE)
* Compiling and running tests from the command-line

#### Assertions
* Assertions overview
* Optional messages
* Checking for equality of primitive types
* Checking for equality of objects
* Checking for equality of iterables
* Checking for matching lines
* Checking for thrown exceptions
* Checking for time-limited execution
* Grouped assertions
* Assertion guards
* Direct failure

#### Life-Cycle Methods
* Loading test data files
* @BeforeEach / @AfterEach annotations
* @BeforeAll / @AfterAll annotations
* Nested test classes

#### Conditional Test Execution
* Assumptions
* Enable/disable test based on OS
* Enable/disable test based on JRE version
* Enable/disable test based on JVM system property value
* Enable/disable test based on OS environment variable value
* Enable/disable test based on result of JavaScript expression

#### Build Tool Support
* Application builds
* Build tool evolution
* What is a dependency
* What is an artefact repository
* How to find 3rd party libraries
* What is transitive dependency
* Source code organization of a project directory
* What is Maven
* Sample POM
* Maven commands
* Maven build phases
* How to run tests in Maven
* Maven test results report
* What is Gradle
* Dependencies in Gradle
* Sample Gradle build file
* The Gradle wrapper
* Gradle test support
* How to run tests in Gradle
* Gradle test results report

#### Using Assertion Libraries
* What is an assertion library
* What is Hamcrest
* What is AssertJ
* Installation of AssertJ
* Usage of AssertJ

#### Mock Objects
* What is a mock object and why you want to use it
* Overview of some mock-objects libraries
* Using Mockito
* Creating mock objects
* Setting up the expected behaviour of the test’s surrounding
* Verifying the outcome
* Argument matchers
* Mock annotation

#### Test Variants
* JUnit 5 configuration
* Parallel test method execution
* Repeated tests
* Parameterized tests
* Parameterized based on simple values
* Parameterized based on enum values
* Parameterized based on values factory method
* Parameterized based on CSV values
* Dynamically generated tests

#### Other Testing Frameworks
* TestNG
* Spock
