Question: fix the tests & helloworld package hw; import static org.junit.Assert.*; import org.junit.After; import org.junit.Before; import org.junit.Test; public class TestHelloWorld { private HelloWorld fixture ; @Before
fix the tests & helloworld package hw; import static org.junit.Assert.*; import org.junit.After; import org.junit.Before; import org.junit.Test; public class TestHelloWorld { private HelloWorld fixture; @Before public void setUp() throws Exception { fixture = new HelloWorld(); } @After public void tearDown() throws Exception { fixture = null; } @Test public void getMessage() { assertNotNull(fixture); assertEquals("hello world", fixture.getMessage()); } @Test public void getMessage2() { // this test is broken - fix it! assertNotNull(fixture); assertEquals("hello world", fixture.getMessage()); } @Test public void getYear() { // this test is OK, fix HelloWorld.java to make it pass! assertNotNull(fixture); assertEquals(2018, fixture.getYear()); } package hw; import java.util.Arrays; public class Main { public static void main(final String[] args) { System.out.println("args = " + Arrays.asList(args)); final HelloWorld instance = new HelloWorld(); System.out.println(instance.getMessage()); System.out.println(instance.getYear()); System.out.println("bye for now"); } }
package hw; public class HelloWorld { public String getMessage() { return "hello world"; } public int getYear() { return 2018; } } }
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
