2014년 12월 4일 목요일

App Inventor Unit testing in windows

I am trying to setup the unit testing before issuing a pull request but am having trouble getting the PhantonJS software to work

I have followed the instructions on  the appinventor\blocklyeditor\tests\README file which states:

For either test, you need to use PhantomJS:  phantomJS:http://phantomjs.org/download.html
To install PhantomJS in MacOSX run:
brew install phantomJS (if you are using homebew)
In other platforms just download the package and put the bin folder in your PATH

I am running under Windows 7.  I downloaded the windows package but is does not contain bin folder just an exe file and some example files. I downloaded the mac version and it does include the bin folder. As the instructions stated to add the bin folder to the PATH I have done this via my windows environment variable using the mac version.

I then ran ant BlocklyTest and get the following result(see the fails in red):

C:\AI\appinventor-sources\appinventor>ant BlocklyTest
Buildfile: C:\AI\appinventor-sources\appinventor\build.xml
BlocklyTest:
init:
BlocklyCompile:
BlocklyTestbed:
BlocklyeditorTests:
    [junit] Running com.google.appinventor.blocklyeditor.BlocklyCodeGeneratorTes
t
    [junit] Tests run: 8, Failures: 8, Errors: 0, Skipped: 0, Time elapsed: 0.10
9 sec
    [junit] Test com.google.appinventor.blocklyeditor.BlocklyCodeGeneratorTest F
AILED
    [junit] Running com.google.appinventor.blocklyeditor.BlocklyEvalTest
    [junit] Tests run: 13, Failures: 13, Errors: 0, Skipped: 0, Time elapsed: 0.
109 sec
    [junit] Test com.google.appinventor.blocklyeditor.BlocklyEvalTest FAILED
[junitreport] Processing C:\AI\appinventor-sources\appinventor\blocklyeditor\rep
orts\TESTS-TestSuites.xml to C:\Users\garethh\AppData\Local\Temp\null1454183468
[junitreport] Loading stylesheet jar:file:/C:/AI/Install-resources/apache-ant-1.
9.0/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-fr
ames.xsl
[junitreport] Transform time: 546ms
[junitreport] Deleting: C:\Users\garethh\AppData\Local\Temp\null1454183468
     [echo] Please see the report at file://C:\AI\appinventor-sources\appinvento
r\blocklyeditor\reports/html/index.html
tests:
BUILD SUCCESSFUL
Total time: 6 seconds


I then reset the path to the windows path that has the exe file and ran the test again this time I had no fails:
C:\AI\appinventor-sources\appinventor>ant BlocklyTest
Buildfile: C:\AI\appinventor-sources\appinventor\build.xml
BlocklyTest:
init:
BlocklyCompile:
BlocklyTestbed:
BlocklyeditorTests:
    [junit] Running com.google.appinventor.blocklyeditor.BlocklyCodeGeneratorTes
t
    [junit] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.30
1 sec
    [junit] Running com.google.appinventor.blocklyeditor.BlocklyEvalTest
    [junit] Tests run: 13, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 11.
921 sec
[junitreport] Processing C:\AI\appinventor-sources\appinventor\blocklyeditor\rep
orts\TESTS-TestSuites.xml to C:\Users\garethh\AppData\Local\Temp\null2107865009
[junitreport] Loading stylesheet jar:file:/C:/AI/Install-resources/apache-ant-1.
9.0/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-fr
ames.xsl
[junitreport] Transform time: 519ms
[junitreport] Deleting: C:\Users\garethh\AppData\Local\Temp\null2107865009
     [echo] Please see the report at file://C:\AI\appinventor-sources\appinvento
r\blocklyeditor\reports/html/index.html
tests:
BUILD SUCCESSFUL
Total time: 25 seconds



I've never run PhantomJS from Windows, so I don't know what the problem might be.
But note that you can try individual tests from the command line so you can check more quickly if
your setup is working:

 phantomJS blocklyeditor/tests/com/google/appinventor/generators_unit/listsCreateWithTest.js

See listsCreateWithTest.js
in generators_unit



Hey Gareth, just place the executable in the path as you are doing.
There are a number of other tests (Java ones) that fail on windows. There's a very old pull request (number 2 or so) that might have been closed (or not), but if you can have a look at that, it'd be great to see if it's not too outdated and actually fixes the issue (it's a windows path issue).



Think I have done the unit test code correct now. I've issued the pull request including the Unit Test and asked for by Hal.

Had a look at the pull request https://github.com/mit-cml/appinventor-sources/pull/2 you mentioned and don't think that this is really an issue myself as in windows you have to reset the JAVA_HOME directory path anyway every time you update javaJDK. This is also the same as Python which at the time of that pull request wasn't needed. I don't think it would be hard for me to add a check in the "AI Project Constructor" software when it startup to make sure the environment variable path for both the javaJDK and python are set correctly and if not will reset it with user confirmation. My "AI Project Constructor 2" is well overdue for release and when I get round to it will add this feature to it.


댓글 없음:

댓글 쓰기