= null) { return this.euroAmount.compareTo(euro.getEuroAmount()); } return 0; } } @Test public void compareEuroClass() { Euro oneEuro = new Euro(1); Euro twoEuro = new Euro(2); // Test that oneEuro equals to it
indexOf –Returns the index of the first occurrence of the specified substring. If the substring does not occur, this method returns -1. Example- String myString1 = 'abcde'; String myString2 = 'cd'; Integer result = myString1.indexOf(mystring2); System.assertEquals(2, result); ...
publicclassTddExample{@TestpublicvoidtestAddTwoNumbers(){assertEquals(3, addTwoNumbers(1,2));} } Running this test would fail because theadd_two_numbers()function doesn't exist yet. Next, you would write the minimal amount of code to make the test pass(Green Phase): ...
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.PrintStream; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; import java.util.SimpleTimeZone; import java.util.TimeZone; import org....