Created
December 13, 2013 14:20
-
-
Save ukiuni/7944932 to your computer and use it in GitHub Desktop.
JUnit(Java)でJavaScriptをテストする。 ref: http://qiita.com/ukiuni@github/items/b16f9d0f2062f59e5f7b
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function plus(x, y) { | |
return x+y; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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