Tuesday, May 04, 2021

Junit 4 to Junit 5 upgrade

 So you started to upgrade from old junit 4 to the new junit 5 api spec.


Sadly the move the packages around. Its best to follow other docs out on the web for this like 

https://www.baeldung.com/junit-filtering-tests


Now heres a gotcha, if you are upgrading your springboot tests from junit4 to junit 5 and are trying to use tags to drop external tests or slow tests and it is not working. 


It might actually be the import Test class that is breaking it.

Replace import org.junit.Test; with import org.junit.jupiter.api.Test;

This should make everything work correctly again.


Then the command below can work.

mvn test  -DexcludedGroups=ExternalIntegrationTest 


No comments: