proiect2 package;
import java.io. *;
public class String {
static BufferedReader buffer = new BufferedReader (new InputStreamReader (System.in));
static String string = null;
public static void main () throws IOException, NumberFormatException {
System.out.println ("Enter string:");
String string = buffer.readLine ();
while (sir.length () == 0) {
System.out.println ("The string is empty");
System.out.println ("Enter a new string:");
string = buffer.readLine ();
}
if (sir.length ()> 0) {
try {
int i = Integer.parseInt (string);
System.out.println ("String:" + string);
System.out.println ("Integer:" + i);
}
catch (NumberFormatException NFE) {
System.out.println ("The string contains invalid characters" + nfe.getMessage ());
}
}
}
}
I must write the JUnit tests, for this java code. But I'm stuck and I don't know how to go further.
A JUnit test, should look like this java code
package proiect2;
import static org.junit.Assert.*;
import org.junit.Test;
public class test1 {
@Test
public void testMain() {
// ??
}
}