06: (4 Points) After running testall methods for class AddSubtracttest2 using JU
ID: 3874672 • Letter: 0
Question
06: (4 Points) After running testall methods for class AddSubtracttest2 using JUNIT what will be printed? Please also indicate the result of each assertion, as either true or false. public class AddSubtract ( private int currentVal: import java.util. import org-junit. public AddSubtract (int a) t curreneva1 a; public class AddSubtractTest2 private AddSubtract asi eBefore public void setup) throws Exception public void add(int a) currentVal +a; as new AddSubtract (4) System.out.printin( Before: Each") public void subtract (int a) currentVala Test public void testAdd) ( public int getCurrentVal) Systen.out.printin( Testl") as.add (5) assertEquals(9, as.getCurrentVal)): return currentVal: Test public void testSubtract ) System.out.println("Test2") as.subtract (5): assertEquals(-1, as.getCurrentVal )) Answer:Explanation / Answer
Before every test method setUp gets called and test method may get execute in any order.
Suppose testAdd gets execute before testSubtract then following get printed
@Before:Each
@Test1
@Before:Each
@Test2
And both assertions will get evaluate to true
In first assertion 4+5=9 will get true
In second assertion 4-5=-1 will get true
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.