This assignment assesses your basic knowledge of Java and JUnit.
Your first task is to develop a Java class called MyString that suitably implements the MyStringInterface interface that we provided. (The semantics of the methods in the interface should be obvious from their name, the JavaDoc comments in the code, and the test examples in class MyStringTest) Class MyString should be in the same package as the interface and should also be saved under < dir>/src/edu/gatech/seclass.
Your second task is to develop a set of JUnit 4 test cases for class MyString by completing the provided template test class MyStringTest, which contains 3 complete test cases and 13 to-be-completed test cases. For each test case in class MyStringTest whose body simply consists of the placeholder "fail("Not yet implemented");", you must do the following:
Replace the placeholder instruction with a meaningful test case for the corresponding method, which is indicated in the comments and name of the test.
Replace the text "< Add test description here>" in the test comment with a concise description of the purpose of the test (e.g., Count strings in an empty string) without modifying anything else in the comment and making sure that your comment consists of a single line (i.e., does not contain newlines) and does not contain quotes or other special characters.
Make sure that every test method has a suitable oracle (i.e., either an assertion or an expected exception) and that the tests are not trivial (i.e., are not a copy of the provided one and have a specific purpose). In other words, each test should (1) test a specific piece of the functionality, and (2) check that such a piece of functionality behaves as expected.
It should be obvious, but please also make sure that all the test cases you created pass when run against your code.
In addition, at least two of the tests that you develop must result in an expected exception (e.g., NullPointerException). When testing for an expected exception, make sure to use the "@Test(expected = < exception class>)" notation (e.g., @Test(expected = NullPointerException.class)), rather than catching the exception within the test body.
Consider, for example, test case testCountNumbersS2():
In your submission, you should have a corresponding, complete test for method countNumbers in class MyString, together with a concise description of the purpose of the method, such as:
@Test // Description: Count numbers in an empty string public void testCountNumbersS2() { < actual test, including the oracle> }
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference
and should not be submitted as is. We are not held liable for any misuse of the solutions.
Please see the frequently asked questions page
for further questions and inquiries.
Kindly complete the form.
Please provide a valid email address and we will get back to you within 24 hours.
Payment is through PayPal, Buy me a Coffee
or Cryptocurrency.
We are a nonprofit organization however we need funds to keep this organization operating
and to be able to complete our research and development projects.