Chris has written a function called toBinary that has an input parameter of an integer number and returns a string that represents the binary equivalent. For example, if the function is called with the integer number 3 then the returned string should be '11'.
Write a sequence of test specifications in English possibly using the "given", "when", and "then" sequence and their equivalent JUnit code.
My answer is:
The test should cover normal cases, extreme cases, and erroneous cases. Given an integer for example 3, it should then covert it to 11 after the method is executed.
@Test
public void testToBinary() {
Binary aBinary = new Binary();
assertEquals(3, 11);
assertEquals(2, 10);
assertFail(10, 8575);
}
is this correct?
toBinary"has an input parameter of an integer", do you mean it takes anintor anInteger? There is nointegerthat I'm aware of. If it takes anInteger, is there well-defined behavior for the null case? If so, does it throw an NPE? If so, can you assert that an NPE is thrown?Integer.MAX_VALUE/Integer.MIN_VALUE