junit and integration tests in OpenOLAT 8 ========================================= * Preconditions ----------------------------------------- - Make sure the following ports are not in use (Selenium, Tomcat 1, Tomcat 2, JMS, MBeanServer(s) ) 4444 / 8181 / 8105 / 8109 / 8282 / 8205 / 8209 / 61616 / 3000 / 3001 / 3002 - Make sure you have a MySQL database version 5.1 or 5.5 with the InnoDB as default engine The server must be at localhost. To change the config see databaseCorecontext.xml - Edit src/test/profile/selenium/config/defaultcontext.xml and add the browserID line (Firefox 3.x only supported): E.g. Firefox on linux box <entry key="browserId" value="*firefox /usr/lib64/firefox/firefox"/> E.g. Firefox verison on a mac <entry key="browserId" value="*firefox /Applications/Firefox3.5.app/Contents/MacOS/firefox-bin"/> - Clone a clean project or remove any olat.local.properties you might have on the classpath. This is important! - Make sure maven has enough memory. E.g execute the following: export MAVEN_OPTS= -Xms512m -Xmx1024m - Make sure the tmp directory is writable. E.g. execute the following. ls -la `printenv TMPDIR` * Setup (necessary only once) ----------------------------------------- - Install tomcats mvn verify -Pinstall-tomcats - Setup database users and tables in the pom.xml. The default settings are: <test.env.db.name>olattest</test.env.db.name> <test.env.db.user>olat</test.env.db.user> <test.env.db.pass>olat</test.env.db.pass> - Setup first an user for the database CREATE USER 'olat'@'localhost' IDENTIFIED BY 'olat'; - Create a first database named olat (the maven create and drop databases automatically and need an existing database to do that) CREATE DATABASE IF NOT EXISTS olat; GRANT ALL PRIVILEGES ON olat.* TO 'olat' IDENTIFIED BY 'olat'; UPDATE mysql.user SET HOST='localhost' WHERE USER='olat' AND HOST='%'; FLUSH PRIVILEGES; - Create the real test database in mysql: CREATE DATABASE IF NOT EXISTS olattest; GRANT ALL PRIVILEGES ON olattest.* TO 'olat' IDENTIFIED BY 'olat'; FLUSH PRIVILEGES; - Initialize the database mysql -u olat -p olattest < src/main/resources/database/mysql/setupDatabase.sql * Execute jUnit integration tests ----------------------------------------- - junit integration tests with MySQL that load the framework to execute (execution time ca. 10-15m) mvn clean test -Dwith-mysql - The junit testresults can be found at target/surefire-reports/* Double click the xml files in Eclipse to display the results in the standards jUnit console * Execute selenium functional integration tests ----------------------------------------- - Selenium functional tests on GUI layer that load OpenOLAT in a two node cluster (execution time ca. 5-6h!) mvn clean verify -Pseleniumtests - The selenium test results can be found at target/failsafe-reports/SeleniumTesting72x/* - When Seleniums don't work, try to debug like this: mvn verify -Pseleniumtests,debug | tee /tmp/mvn72x.log | grep execution - It is recommended to use a Jenkins setup to administrate the test results. The Selenium results have the same format as the junit test protocols * Execute a single selenium functional integration test in Eclipse ----------------------------------------- - Start Eclipse, refresh project and wait until Eclipse is finished with refreshing and compiling - In a shell run the following command to start the test cluster: mvn verify -Pseleniumtests,debug | tee /tmp/mvn72x.log | grep execution - Wait until the servers have started (in the log /tmp/mvn72.log an information appears that the server can be stopped with Crl-C) - In Eclipse right-click a selenium testcase form src/test/java/org/olat/test/functional/* and select "run in jUnit" * Execute a single selenium functional integration test on the command line ----------------------------------------- - Configure the tests to be run in the file src/test/profile/selenium/config/testng.xml - Run the tests mvn clean verify -Pseleniumtests * Fixing Selenium testcases ----------------------------------------- - Fix broken code or broken testcases in src/test/profile/selenium/ui-map/* - When changing the pagesets, update UI-map afterwards using the following command mvn clean package -Pseleniumtests