-1

I want to use ErrorCollector class in jUnit but not able to import its required class. I want to import org.junit.rule.* but instead of that i get option for importing import sun.org.mozilla.javascript.internal.ast.ErrorCollector. I do not understand what is happening. I do not get any option for importing Rule class, I tried to type import org.junit.rule but its not imported successfully. Please help or explain me what is going on?

Thanks.

package testcases;

import junit.framework.Assert;
import org.junit.Test;
//import sun.org.mozilla.javascript.internal.ast.ErrorCollector;

public class understandingAssertion {

    @Rule
    public ErrorCollector er = new ErrorCollector();

    @Test
    public void countFriendTest() {
        int actual_fr = 100; //Selenium
        int expected_Fr =10;

        /*
        if (actual_fr == expected_Fr) {
            System.out.println("Pass");
        } else {
            System.out.println("Fail");
        }
        */

        System.out.println("A");
        try
        {
            Assert.assertEquals(expected_Fr, actual_fr);
        }
        catch(Throwable e)
        {
            System.out.println("Error encountered");
        }
    }
}
user1766760
  • 631
  • 2
  • 8
  • 26
Jak
  • 1
  • 4

1 Answers1

0

Your IDE will probably only give you the option to import classes that exist on your classpath.

Add the jar to your classpath and you'll be able to import the class without error.

pauljwilliams
  • 19,079
  • 3
  • 51
  • 79