Skip to content
Snippets Groups Projects
TESTING.README.LATEST 3.32 KiB
Newer Older
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
-----------------------------------------
srosse's avatar
srosse committed
- junit integration tests that load the framework to execute (execution time ca. 10-15m)
  - MySQL
	  mvn clean test -Dwith-mysql
  - PostgreSQL
	  mvn clean test -Dwith-postgresql 
  - 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
	  

- 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
-----------------------------------------
- First build the application without tests (arquillian need the library before mvn give them)
    mvn -DskipTests=true -Parquillian clean package
    
- Run the tests
srosse's avatar
srosse committed
	mvn -Parquillian surefire:test


* Execute a single selenium functional integration test in Eclipse
-----------------------------------------
- First build the application without tests as before
    mvn -DskipTests=true -Parquillian clean package
 
- Run single test as JUnit Test in Eclipse