JUnit

JUnit Assert Exception - JUnit 5 and JUnit 4 — step-by-step Programming tutorial on Progressive Robot

JUnit Assert Exception – JUnit 5 and JUnit 4

URL: https://www.progressiverobot.com/junit-assert-exception-expected/ We can test expected exceptions using [JUnit 5](/community/tutorials/junit5-tutorial) assertThrows assertion. This [JUnit assertion](/community/tutorials/junit-assertions) method returns the thrown exception, so we can use it to assert exception message too. JUnit Assert Exception Here is a simple example showing how to assert exception in JUnit 5. String str = null; assertThrows(NullPointerException.class, () -> str.length()); JUnit […]

Read more
JUnit Display Name - @DisplayName — step-by-step Programming tutorial on Progressive Robot

JUnit Display Name – @DisplayName

URL: https://www.progressiverobot.com/junit-display-name-displayname/ JUnit @DisplayName annotation is used to provide a custom name for the test class and test methods. We can use spaces, special characters, and even emojis in the display name. JUnit Display Name Example By default, [JUnit](/community/tutorials/junit5-tutorial) reporting prints the class name and method name in the IDE test report. We can use […]

Read more
JUnit HTML Report — step-by-step Programming tutorial on Progressive Robot

JUnit HTML Report

URL: https://www.progressiverobot.com/junit-html-report/ When we configure maven-surefire-plugin to run our JUnit tests, it generates surefire-reports directory. This directory contains a txt file and an XML file for every test class. However, reading these files is not easy and it's also not easily explainable to a non-techie person. JUnit HTML Report We can use maven-surefire-report-plugin plugin to […]

Read more
JUnit Setup Maven - JUnit 4 and JUnit 5 — step-by-step Programming tutorial on Progressive Robot

JUnit Setup Maven – JUnit 4 and JUnit 5

URL: https://www.progressiverobot.com/junit-setup-maven/ JUnit 4 and JUnit 5 are completely different frameworks. They both serve the same purpose, but the JUnit 5 is a completely different testing framework written from scratch. It's not using anything from JUnit 4 APIs. Here we will look into how to setup JUnit 4 and [JUnit 5](/community/tutorials/junit5-tutorial) in our maven projects. […]

Read more
JUnit5 Tutorial — step-by-step Programming tutorial on Progressive Robot

JUnit5 Tutorial

URL: https://www.progressiverobot.com/junit5-tutorial/ JUnit5 Tutorial In this Junit tutorial, we will introduce basics of JUnit5 and its new features using examples. In Java world, JUnit is one of the popular framework used to implement unit tests against java code. JUnit primarily helps developers to test their code on the [JVM](/community/tutorials/java-jvm-memory-model-memory-management-in-java) by themselves. JUnit5 Architecture JUnit Platform […]

Read more
CHAT