



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Class: Full Course Title: Program Design and Development; Subject: COMPUTER SCIENCE; University: University of Arizona; Term: Unknown 1989;
Typology: Assignments
1 / 5
This page cannot be seen from the preview
Don't miss anything!




middleTwo("abcd") โ "bc" middleTwo("abcde") โ "bc"
// This class has tests for two methods to provide practice for testing // methods that process Strings and some of the primitive types. // Programmer: Rick Mercer import static org.junit.Assert.*; import org.junit.Test;
public class TwoMethodsTest {
@Test public void testMiddleTwo() { // Need a TwoMethods object to send messages to TwoMethods myFuns = new TwoMethods();
// Four test cases to test the middleTwo method assertEquals ("bc", myFuns.middleTwo("abcd")); assertEquals ("bc", myFuns.middleTwo("abcde")); assertEquals ("23", myFuns.middleTwo("12345")); assertEquals ("pu", myFuns.middleTwo("Computers")); assertEquals ("to", myFuns.middleTwo("to")); assertEquals ("is", myFuns.middleTwo("antidisestablishmentarianism"));
// Our tests will not violate the precondition with cases like this // that would throw an indexOutOfBoundsException // assertEquals("to", myFuns.middleTwo("a")); // assertEquals("to", myFuns.middleTwo(""));
} // One more test method will be completed below }
// Determine and return the middle two chars of the String argument. public String middleTwo(String arg) { return "TBA"; // Change this method body }
// More methods to be completed below }
isEven (24) โ true isEven (25) โ false
@Test public void testIsEven() { TwoMethods myFuns = new TwoMethods(); assertTrue (myFuns.isEven(24)); // ... add other assertions to fully test isEven }