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

Reply via email to