I apologize for the cross-posting, but I perhaps shouldn’t have put my original request on Code Help. I’m a teacher writing JUnit tests for my assignments. One of my tests needs to have “throws IOException” after the method header, but I can’t add to that line (the cursor won’t let me type there). Here’s the code I have in the system:
public void NotUsingMathClassTest ( ) {
int count = 0;
String learner_code = new String(Files.readAllBytes(Paths.get("Main.java")));
String[] words = learner_code.split(" ");
System.out.println(words.length);
for (int i = 0; i < words.length; i++)
{
if (words[i].indexOf("Math.") >= 0)
{
count++;
}
}
assertFalse(count > 0);
}
}
It works in another IDE if the method header reads public void NotUsingMathClassTest ( ) throws IOException.