3

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?

4
  • 1
    Comment out Test annotation, e.g. //@Test Jan 26, 2017 at 19:24
  • 3
    Just to be sure: add import org.junit.Ignore; to import list to use @Ignore Jan 26, 2017 at 19:26
  • @DarshanMehta It didn't work, I am still getting the compiler error
    – SteelToe
    Jan 26, 2017 at 19:26
  • 1
    @defaultlocale It worked like a charm, Thanks
    – SteelToe
    Jan 26, 2017 at 19:27

1 Answer 1

7

@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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.