I have the following Junit test class
package Md5Tests;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
import timebackup.*;
/**
*
* @author jack
*/
public class PathNodeToXmlTest {
public PathNodeToXmlTest() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
@Test
public void createXml() {
PathNode root = new PathNode(true, "docs", "0");
root.addPathNode(new PathNode(true, "docs sub folder", "1"));
root.addPathNode(new PathNode(false, "docs sub file", "2"));
PathNodeToXml xmlCreator = new PathNodeToXml(root);
System.out.println(xmlCreator);
}
}
I am now trying to temporarily stop the test createXml()
from being run by the test runner. I have tried adding the @Ignore
annotation right before the @Test
annotation however the compiler throws an error saying that it can't find the symbol for @Ignore
. I am using the NetBeans Ide.
Anyone have any ideas either how to prevent the compile error, or another way to temporarily prevent a JUnit test from running?
Since JUnit5 the @Disabled annotation is used to signal that the annotated test class or test method is currently disabled and should not be executed:
import org.junit.jupiter.api.Disabled
class ExampleClass {
@Disabled("This test is disabled")
@Test
void testWillBeDisabled() {
}
}
Also see Disabling Tests in JUnit 5 User Guide.
Thanks to @jakobleck for JUnit 5 update
@Ignore annotation is in a package org.junit
so you need to add import statement
import org.junit.Ignore;
or
import org.junit.*;
Next time you have a problem like this you can just google class name (e.g. junit @Ignore
) go to the documentation page and check package name.
In NetBeans you can use "Source -> Fix Imports" command (Ctrl + Shift + I) and IDE will try to resolve necessary imports automatically.