Skip to content
Advertisement

Tag: junit5

Expecting exception during MockMVC.perform in JUnit5

This may be a repeated question. But I have gone through some 10-15 related posts and associated responses which have not resolved my issue. The issue that I am facing is as here below I have a SpringRest controller class with custom ApplicationException. I have written a Junit for my controller and here below is the snippet where I am

junit 5 custom parametrized tests

I’m using Junit 5 parametrized tests with custom name as follow where PARAMETERIZED_TESTS_NAME_PLACEHOLDER is defined in its own utility class the problem I’m facing is that as I’m using extensively the parametrized tests, my code is cluttered by these @ParameterizedTest(name = PARAMETERIZED_TESTS_NAME_PLACEHOLDER). so I created a custom annotation to fix this but this annotation is ignored when I use it

Setting up properly SonarQube for Code Coverage

I’m using JUnit5 on a SpringBoot backend application server using Maven. Here is the sonar-project.properties file that is at the root of the project: I use the sonar-scanner command line to run update the project after a build/test. The Overview board on sonar-cloud looks like this: I at least got the unit tests to be recognized, but somehow I’m still

JUnit5: Specify order of execution of multiple @Nested classes

Does Junit5 give any guarantees regarding execution order of @Nested classes defined within the same parent? With a trivial example I made, I notice the tests are executed in reverse order of declaration, but this behavior is neither documented (or is it?) nor consistent with how @Test annotated methods are ordered by default. It’s also quite annoying, because obviously I’d

How to get rid of TemporaryFolder rule in Junit5

I’m migrating unit tests from Junit4 to Junit5. In the test I’m using TemporaryFolder rule from Junit4 API. To keep the test working I added @EnableRuleMigrationSupport annotation: As I understand, in Junit5 I need to use extensions instead of rules, but I can’t find any replacement for TemporaryFolder in Junit5 extensions. Does it exist? How to correctly replace TemporaryFolder rule

Advertisement