Question: Consider the following JUnit Test Class public class Test{ Set s = new HashSet(); @Before public void setUp(){ s = new HashSet(); s.add (cat); s.add

Consider the following JUnit Test Class

public class Test{

Set s = new HashSet();

@Before public void setUp(){

s = new HashSet();

s.add ("cat");

s.add ("dog");

}

@Test public void test1() {

s.add ("cat");

assertTrue ("Size is 2", s.size() == 2);

}

@Test public void test2(){

s.remove ("cat");

assertTrue ("Size is 1", s.size() == 1);

s.add ("elephant");

assertTrue ("Size is 2", s.size() == 2);

}

}

2. What is wrong with test2()? How should test2() be repaired?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!