-1

I am writing Junit test cases for the following method. The Junit test case is below it. I can't seem to figure out what to test or how to?

//method
package try.out;
public class MyString implements MyStringInterface{
    public static String str;   
    public void removeChar(char C){

        str = MyString.str.replace("C", "");
        System.out.println(str);
    }

//testcase. 
@Test
public void testremoveChar() {
    MyString test = new MyString();
    //what do i do next?
}
javabeginner
  • 91
  • 3
  • 11
  • 1
    I've tracked some of your questions recently and have to suggest that you consider opening a book. Most of your questions can be easily answered by simply studying your text. The knowledge gained and the skills at self learning gained will be directly useful for your future projects and problems, trust me. – Hovercraft Full Of Eels Sep 05 '14 at 23:43

1 Answers1

1

The implementation of removeChar is probably wrong, but that's why you're writing a test no?

I would write

@Test
public void testremoveChar() {
    MyString test = new MyString();
    MyString.str = "This is a Complete Test";
    test.removeChar('T');
    assertEquals("his is a Complete est", MyString.str);
}

It will fail, but looking at the output you can improve the method until you get what expected.

Simone Gianni
  • 11,426
  • 40
  • 49