Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
JUnit(Java)でJavaScriptをテストする。 ref: http://qiita.com/ukiuni@github/items/b16f9d0f2062f59e5f7b
function plus(x, y) {
return x+y;
}
@Test
public void testPlus() throws ScriptException, IOException {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript");
FileReader reader = new FileReader("WebContent/js/scriptTobeTested.js");
engine.eval(reader);
Assert.assertEquals(true, engine.eval("plus(1, 1) == 2"));
reader.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.