Question: CODE MyCustomStringTest.java package edu.qc.seclass; import org.junit.After; import org.junit.Before; import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; public class MyCustomStringTest { private MyCustomStringInterface mycustomstring; @Before public

 CODE MyCustomStringTest.java package edu.qc.seclass; import org.junit.After; import org.junit.Before; import org.junit.Test; importstatic org.junit.Assert.assertEquals; import static org.junit.Assert.fail; public class MyCustomStringTest { private MyCustomStringInterface mycustomstring;@Before public void setUp() { mycustomstring = new MyCustomString(); } @After publicvoid tearDown() { mycustomstring = null; } @Test public void testCountNumbers1() {

CODE

MyCustomStringTest.java

package edu.qc.seclass;

import org.junit.After; import org.junit.Before; import org.junit.Test;

import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail;

public class MyCustomStringTest {

private MyCustomStringInterface mycustomstring;

@Before public void setUp() { mycustomstring = new MyCustomString(); }

@After public void tearDown() { mycustomstring = null; }

@Test public void testCountNumbers1() { mycustomstring.setString("I'd b3tt3r put s0me d161ts in this 5tr1n6, right?"); assertEquals(7, mycustomstring.countNumbers()); }

@Test public void testCountNumbers2() { fail("Not yet implemented"); }

@Test public void testCountNumbers3() { fail("Not yet implemented"); }

@Test public void testCountNumbers4() { fail("Not yet implemented"); }

@Test public void testCountNumbers5() { fail("Not yet implemented"); }

@Test public void testCountNumbers6() { fail("Not yet implemented"); }

@Test public void testGetEveryNthCharacterFromBeginningOrEnd1() { mycustomstring.setString("I'd b3tt3r put s0me d161ts in this 5tr1n6, right?"); assertEquals("d33p md1 i51,it", mycustomstring.getEveryNthCharacterFromBeginningOrEnd(3, false)); }

@Test public void testGetEveryNthCharacterFromBeginningOrEnd2() { mycustomstring.setString("I'd b3tt3r put s0me d161ts in this 5tr1n6, right?"); assertEquals("'bt t0 6snh r6rh", mycustomstring.getEveryNthCharacterFromBeginningOrEnd(3, true)); }

@Test public void testGetEveryNthCharacterFromBeginningOrEnd3() { fail("Not yet implemented"); }

@Test public void testGetEveryNthCharacterFromBeginningOrEnd4() { fail("Not yet implemented"); }

@Test public void testGetEveryNthCharacterFromBeginningOrEnd5() { fail("Not yet implemented"); }

@Test public void testGetEveryNthCharacterFromBeginningOrEnd6() { fail("Not yet implemented"); }

@Test public void testGetEveryNthCharacterFromBeginningOrEnd7() { fail("Not yet implemented"); }

@Test public void testGetEveryNthCharacterFromBeginningOrEnd8() { fail("Not yet implemented"); }

@Test public void testGetEveryNthCharacterFromBeginningOrEnd9() { fail("Not yet implemented"); }

@Test public void testGetEveryNthCharacterFromBeginningOrEnd10() { fail("Not yet implemented"); }

@Test public void testGetEveryNthCharacterFromBeginningOrEnd11() { fail("Not yet implemented"); }

@Test public void testGetEveryNthCharacterFromBeginningOrEnd12() { fail("Not yet implemented"); }

@Test public void testGetEveryNthCharacterFromBeginningOrEnd13() { fail("Not yet implemented"); }

@Test public void testGetEveryNthCharacterFromBeginningOrEnd14() { fail("Not yet implemented"); }

@Test public void testConvertDigitsToNamesInSubstring1() { mycustomstring.setString("I'd b3tt3r put s0me d161ts in this 5tr1n6, right?"); mycustomstring.convertDigitsToNamesInSubstring(17, 23); assertEquals("I'd b3tt3r put sZerome dOneSix1ts in this 5tr1n6, right?", mycustomstring.getString()); }

@Test public void testConvertDigitsToNamesInSubstring2() { fail("Not yet implemented"); }

@Test public void testConvertDigitsToNamesInSubstring3() { fail("Not yet implemented"); }

@Test public void testConvertDigitsToNamesInSubstring4() { fail("Not yet implemented"); }

@Test public void testConvertDigitsToNamesInSubstring5() { fail("Not yet implemented"); }

@Test public void testConvertDigitsToNamesInSubstring6() { fail("Not yet implemented"); }

@Test public void testConvertDigitsToNamesInSubstring7() { fail("Not yet implemented"); }

@Test public void testConvertDigitsToNamesInSubstring8() { fail("Not yet implemented"); }

}

5. Your first task is to develop a Java class called MyCustomString that suitably implements the MycustomstringInterface that we provided. (The semantics of the methods in the interface should be obvious from their name and from the JavaDoc comments in the code. If not, please ask on Piazza.) Class MyCustomstring should be in the same package as the interface and should also be saved under dir/src/ edu/qc/seclass. 6. Your second task is to develop a set of JUnit 4.0 test cases for class MyCustomstring. - You should create several test cases for each method that implements a method in the interface, except for getters and setters (i.e., the first two methods). Make sure that every test method has a suitable oracle (i.e., either an assertion or an expected exception), that the tests are not trivial (i.e., have a specific purpose). In other words, each test should (1) test a specific piece of functionality and (2) check that such piece of functionality behaves as expected. - In addition, for each exception that can be thrown by a method M and is explicitly mentioned in M's documentation, there should be at least one test for M that results in that expected exception. For example, at least three of the tests for method convertDigitsToNamesinsubstring should result in expected exceptions: - One for IllegalargumentException - One for MyIndexOutOfBoundsException - One for NullPointerException - When testing for an expected exception, make sure to use the @Test(expected= > ) notation. For example: eTest (expected = MyIndexOutOfBoundsException.class) public void testConvertDigitsToNamesInsubstring8() i \} - To make your job a little easier, the archive also contains, in directory dir / test, a test cases that you need to implement and a complete implementation for a few of them. Your job is to write the body of the test cases that are not implemented (i.e., the one that simply fail with a "Not yet implemented" message). Make also sure that the test cases you write are not just a trivial variation of the ones we provide. To this end, make sure to add a concise comment to each test that you implement to clarify its rationale (e.g.,. "This test checks whether the method convertDigitsToNames InSubstring suitably throws an IllegalArgumentException if startPosition is greater than endPosition"). Finally, creating more than the required test cases will not be rewarded nor penalized; in other words, feel free to write more tests if you are so inclined, but you will have to provide at least as many tests as there are skeletons. 7. Submit your solution by - Pushing and all the files and directories underneath it (except for the files excluded by .gitignore, if you have one, such as all class files) to the individual remote GitHub repository we assigned to you. You can decide whether to commit Eclipse or IDEA's project related files, as this does not make a difference for us, but the repo must necessarily contain the two files: - Assignment 3/src/edu/qc/seclass/MyCustomStringjava Assignment3/test/edu/qc/seclass/MyCustomstringTest. java Submitting the commit ID for your submission on Blackboard. You can get your commit ID by running "git log1 ". (J) MyCustomStringlnterface.java 3 MylndexOutOfBoundsException.java ) MyCustomStringTest.java D MyCustomStringlnterface.java () MylndexOutOfBoundsException.java \& 3 D) MyCustomStringTest.java

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!