Skip to content

Instantly share code, notes, and snippets.

@ukiuni
Created December 13, 2013 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ukiuni/7944932 to your computer and use it in GitHub Desktop.
Save ukiuni/7944932 to your computer and use it in GitHub Desktop.
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