Parse Student Code
import org.junit.Test;
import static org.junit.Assert.*;
import java.nio.file.*;
public class CodingRoomsUnitTests {
@Test
public void testDefaultCase() throws Exception {
int count = 0;
String student_code = new String(Files.readAllBytes(Paths.get("Example.java")));
String[] words = student_code.split(" ");
for (int i = 0; i < words.length; i++) {
if (words[i].indexOf("System.out.println(") >= 0) {
count++;
}
}
assertTrue(count >= 2);
}
}Last updated
Was this helpful?