Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
TESTING.README.LATEST 3.88 KiB
junit and integration tests in OpenOLAT 8
=========================================

* Preconditions
-----------------------------------------
- Make sure the following ports are not in use (Selenium, Tomcat )
	14444 / 8080 / 8009 / 8089 

- 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

- 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)
-----------------------------------------
- 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 that load the framework to execute (execution time ca. 10m)
  - MySQL
	  mvn clean test -Dwith-mysql -Ptomcat
	  or with more options
	  mvn clean test -Dwith-mysql -Dtest.env.db.user=root -Dtest.env.db.pass=serial -Ptomcat
	  
  - PostgreSQL
	  mvn clean test -Dwith-postgresql -Ptomcat
	  or if you want to specify the password:
	  mvn clean test -Dwith-postgresql -Dtest.env.db.postgresql.pass=serial -Ptomcat
	  
  - Oracle
    The support of Oracle is still EXPERIMENTAL
    - you need a clean database as the maven process doesn't create a new one (every time)
    - You need more cursors (if you don't know what it is, don't run this tests :-): 
      ALTER SYSTEM SET open_cursors = 400 SCOPE=BOTH;
    - configure the olat.local.properties in src/test/profile/oracle
    - you need to install the JDBC driver locally (one time) as there isn't any maven repo for them (licensing issue)
      mvn install:install-file -Dfile=ojdbc6.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.0 -Dpackaging=jar -DcreateChecksum=true
	then you can run the test suite
	  mvn clean test -Dwith-oracle -Ptomcat
	  
- 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 integration tests which started the whole web application in Tomcat (execution time ca. 30 - 45m)
  - MySQL
	mvn clean verify -DskipTests=true -Dwith-mysql -Ptomcat
  - PostgreSQL
	mvn clean verify -DskipTests=true -Dwith-postgresql -Dtest.env.db.postgresql.pass=serial -Ptomcat

The Selenium tests can be run with Chrome browser. It need to be installed the standard way on
Mac or Linux and the test process will download the WebDriver and found the browser.

* Execute a single selenium functional integration test in Eclipse
------------------------------------------------------------------
- First build the application without tests as before
	mvn clean verify -DskipTests=true -DskipSeleniumTests=true -Ptomcat

- Run single test as JUnit Test in Eclipse