ERP 2.50:Automated Testing/Execute from command line
First, you need to have a working installation of Openbravo ERP.
Check out Openbravo ERP automation source code
To be able to clone Openbravo ERP testing code from main you need to install Mercurial.
Once Mercurial client is installed, move to the directory where you want to clone the last testing code tag and type in command line:
hg clone https://code.openbravo.com/tools/automation/pi/ pi
Move to pi/config directory and configure OpenbravoERPTest.properties.
Then, you need to install some things:
Execute Openbravo ERP tests
Execute a suite
You can use ant to execute the different tests suites already automated. The default execution is parallelized, but you can also run the tests sequentially.
Our default suite execution uses Selenium Grid and the Ant parallel task in order to launch multiple tests at once and reduce the execution time as much as possible.
So, before launching the test suite you will have to prepare the environment and start the grid components.
First, create a Firefox profile for each Remote Controller that will be used on the execution. Otherwise, they will share the Openbravo session and everything will fail. The following command will create a new profile named "rc1":
firefox -no-remote -CreateProfile rc1
And it will return the path to that newly create profile, that will be required later. It's something like:
Then, go to the automation branch folder and start the hub:
ant seleniumhub.start < /dev/null &
After that, start the Remote Controllers:
ant -Dport=5555 -DseleniumArgs="-firefoxProfileTemplate /srv/hudson/.mozilla/firefox/g2jc2ulk.rc1"
Some important things to note:
Finally, you will be able to run the suite.
For example, with:
ant test.integration.smoke -f src-test/com/openbravo/test/integration/erp/testsuites/smoke/build.xml
ant will run the smoke test suite.
There are two ways to run the tests sequentially:
- Starting the Selenium Hub and only one Remote Controller.
- Passing the sequential argument to ant.
This second option will not work with the default build file because it is now parallelized. Thus, many requests will get to the Selenium Server and as it is sequential it will be able to attend only one at a time, rejecting the rest.
We have kept a sequential build file for the smoke suite so we can execute it using the previous sequential components. But for the rest suites we will provide only the parallel ant build.
To run the smoke suite sequentially, run:
ant -Dsequential=true test.integration.smoke -f src-test/com/openbravo/test/integration/erp/testsuites/smoke/build.sequential.xml
We recommend to use the new parallel components, starting the grid and one or more RCs. This sequential execution is useful when you want to execute only one test, as explained in the next section.
Execute a test
You can run a specific test class with:
ant test.integration -Dsequential=true -Dtestclass=com.openbravo.test.integration.erp.testsuites.smoke.masterdata.ADM0000_Logging
replacing com.openbravo.test.integration.erp.testsuites.smoke.masterdata.ADM0000_Logging with the test class you want to run.
Note: The -Dsequential parameter is just to make the execution easier. You can omit it, but before running the test you must have started the Selenium hub and at least one Remote Controller
Running on a headless server
X virtual framebuffer can be used if the server that will be used to execute selenium tests has no X Window System.
To run the virtual framebuffer as display ":1", execute:
startx -- `which Xvfb` :1 -screen 0 1024x768x24 2>&1 >/dev/null &
Then, to run the tests do something like this:
DISPLAY=:1 ant test.integration.smoke
The following instruction are specific to Ubuntu. Adjust them for your system.
- Install the required package
apt-get install tightvncserver icewm
- Create a user name (i created user openbravo) and create xstartup
mkdir ~/.vnc touch ~/.vnc/xstartup chmod a+x ~/.vnc/xstartup
- Add the following content in ~/.vnc/xstartup
#!/bin/sh xrdb $HOME/.Xresources xsetroot -solid black exec icewm-session
- Start the vncserver
vncserver -geometry 1280x960 -depth 8
- Stop the vncserver
vncserver -kill :1
- Try connecting from your machine
- If not connecting do the following
- Make sure vncserver is running (cmd:pgrep Xtightvnc)
- Check on what port its listening (cmd: netstat -anpt | grep Xtightvnc)
- Make sure that the required policy is added in the firewall