Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
JUnit(Java)でJavaScriptをテストする。 ref:
function plus(x, y) {
return x+y;
public void testPlus() throws ScriptException, IOException {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript");
FileReader reader = new FileReader("WebContent/js/scriptTobeTested.js");
Assert.assertEquals(true, engine.eval("plus(1, 1) == 2"));
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.