i'm trying to run a sahi test suite on my laptop and getting some weird behavior (open source [OS] version install_sahi_v35_20110719.jar).
here's my suite file, smoketest.suite:
// smoketest tests. Run a few simple tests
test1.sah
test2.sah
test3.sah
test4.sah
test5.sah
test6.sah
test7.sah
test8.sah
i run this using ant (run target runSingleTestSahi):
<target name="runSingleTestSahi">
<antcall target="start-web" />
<antcall target="sahiTest" />
<antcall target="stop-web" />
</target>
<target name="sahiTest">
<echo>testrunner start</echo>
<exec executable="../testing/sahi/userdata/bin/testrunner.sh" failonerror="true" osfamily="unix">
<arg value="smoketest.suite" />
<arg value="http://a.localtestserver.no:8080" />
<arg value="firefox" />
</exec>
<echo>testrunner end</echo>
</target>
<target name="start-web" description="starts web">
<echo>start web start</echo>
<exec executable="../testing/sahi/userdata/bin/start_sahi.sh" osfamily="unix" spawn="true"/>
<echo>start web end</echo>
</target>
<target name="stop-web" description="stop web server">
<echo>stop-web start</echo>
<get dest="stopserver.htm" src="http://localhost:9999/dyn/stopserver" ignoreerrors="true" />
<delete file="stopserver.htm"/>
<echo>stop-web end</echo>
</target>
when i run this smoketest.suite, firefox windows popup and i can see some of the scripts get run. after 150 seconds the script stops/times out and the log shows that some of the scripts are red. if i click on one it shows the following error:
ERROR
Script did not start within 150 seconds.
when i tried running the scripts that failed, individually, they would always give me the error:
firefox closed unexpectedly while starting...
but the second time i would run them, they would complete successfully.
SOLUTION:
i found out that it was the number of threads (default 5) defined in testrunner.sh that was causing the problem. when i changed it from 5 to 1 (cue doors music ;), then the whole suite ran without problems--it just takes more time to complete the test, but at least it works. :)
change:
export THREADS=5
to:
export THREADS=1
FULLY QUALIFIED PATHS IN SH SCRIPTS
another thing i had to do was convert all PATH values to fully qualified paths, instead of relative paths, otherwise, if i tried running the scripts with ant, it would give me the following error:
[exec] Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/sahi/test/TestRunner
[exec] Caused by: java.lang.ClassNotFoundException: net.sf.sahi.test.TestRunner
[exec] at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
[exec] at java.security.AccessController.doPrivileged(Native Method)
[exec] at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
[exec] at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
[exec] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
[exec] at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
[exec] Could not find the main class: net.sf.sahi.test.TestRunner. Program will exit.
files with PATHs that needed to be changed (change the red parts of the paths to where you installed sahi):
sahi/userdata/bin/start_sahi.sh
#################
#!/bin/bash
export SAHI_HOME=/home/me/eclipseWorkspace/myApp/testing/sahi
export SAHI_USERDATA_DIR=$SAHI_HOME/userdata
export SAHI_EXT_CLASS_PATH=
. $SAHI_HOME/bin/sahi.sh
#################
sahi/userdata/bin/testrunner.sh
#################
#!/bin/bash
if [ $# -ne 3 ]
then
echo "Usage: testrunner.sh <sah file|suite file> <startURL> <browserType>"
echo "File path is relative to userdata/scripts"
echo "Example:"
echo "testrunner.sh demo/demo.suite http://sahi.co.in/demo/ <browserType>"
echo "testrunner.sh demo/sahi_demo.sah http://sahi.co.in/demo/ <browserType>"
else
export SAHI_HOME=/home/me/eclipseWorkspace/myApp/testing/sahi
export USERDATA_DIR=$SAHI_HOME/userdata
export SCRIPTS_PATH=$USERDATA_DIR/scripts/$1
export BROWSER=$3
export START_URL=$2
export THREADS=1
export SINGLE_SESSION=true
java -cp $SAHI_HOME/lib/ant-sahi.jar net.sf.sahi.test.TestRunner -test $SCRIPTS_PATH -browserType "$BROWSER" -baseURL $START_URL -host localhost -port 9999 -threads $THREADS -useSingleSession $SINGLE_SESSION
fi
#################
sahi/bin/sahi.sh
#################
if [ ! $SAHI_HOME ]
then
export SAHI_HOME=/home/me/eclipseWorkspace/myApp/testing/sahi
fi
if [ ! $SAHI_USERDATA_DIR ]
then
export SAHI_USERDATA_DIR_TMP=$SAHI_HOME/userdata
else
export SAHI_USERDATA_DIR_TMP=$SAHI_USERDATA_DIR
fi
echo --------
echo SAHI_HOME: $SAHI_HOME
echo SAHI_USERDATA_DIR: $SAHI_USERDATA_DIR_TMP
echo SAHI_EXT_CLASS_PATH: $SAHI_EXT_CLASS_PATH
echo --------
SAHI_CLASS_PATH=$SAHI_HOME/lib/sahi.jar:$SAHI_HOME/extlib/rhino/js.jar:$SAHI_HOME/extlib/apc/commons-codec-1.3.jar
java -classpath $SAHI_EXT_CLASS_PATH:$SAHI_CLASS_PATH net.sf.sahi.Proxy "$SAHI_HOME" "$SAHI_USERDATA_DIR_TMP"
#################
see also how to run sahi tests as a sahi ant task
IT, computer and programming tutorials and tips that i couldnt find anywhere else using google, from my daily work as a Senior Developer of solutions using Java and Linux.
Subscribe to:
Post Comments (Atom)
How did you change from 5 threads to 1 Thread
ReplyDeletein testrunner.sh (see description above)
Delete