Thanks for noting Stamatis! If a particular group of tests is migrating to JUnit 5, it also probably makes sense to use org.junit.jupiter.api.Assertions instead of org.junit.Assert. Although the latter is still supported, I think it makes sense to use things in the jupiter namespace where possible.
-- Michael Mior mm...@apache.org Le lun. 2 déc. 2019 à 07:53, Stamatis Zampetakis <zabe...@gmail.com> a écrit : > > Hello, > > At the moment, we can use both JUnit 4 and 5 annotations in our code base. > Lately, I spend some time on debugging a few test cases only to realize > that old and new APIs do not mix very well. If you encounter problems with > your annotations then consider checking your imports. The problem might lie > on the fact that you are using at the same time annotations from different > versions. > > Consider for example the following test. > > import org.junit.Assert; > import org.junit.Test; > import org.junit.jupiter.api.Disabled; > > public class SimpleTest { > > @Test > @Disabled > public void test() { > Assert.fail("Should not run because it is disabled"); > } > } > > Contrary to what people might expect the test above will run and will fail > with an assertion error. Changing the imports (see below) will make the > test behave as expected. > > package org.apache.calcite; > > import org.junit.Assert; > import org.junit.jupiter.api.Test; > import org.junit.jupiter.api.Disabled; > > public class SimpleTest { > > @Test > @Disabled > public void test() { > Assert.fail("Should not run because it is disabled"); > } > } > > Best, > Stamatis