Skip to content

Unit Testing with MS SQL Server (based on TG Air project)

01es edited this page Oct 14, 2019 · 1 revision
  1. Add user-specific testing profile in ttgams-dao/pom.xml -- e.g.

	<profile>
		<id>sqlServer-User1</id>
		<properties>
			<databaseUri.prefix>//localhost:1433;database=TG_AIR_TEST_DB_</databaseUri.prefix>
			<fork.count>3</fork.count>
		</properties>
	</profile>
  1. Create database login instance named junit as per expectations in ttgams-dao/src/main/java/fielden/test_config/SqlServerDomainDrivenTestCaseRunner.java

  2. Create required number of empty database instances according to naming pattern in added profile (i.e. TG_AIR_TEST_DB_1, TG_AIR_TEST_DB_2, TG_AIR_TEST_DB_3)

  3. Create database user from junit login instance in each database (i.e. TG_AIR_TEST_DB_1, TG_AIR_TEST_DB_2, TG_AIR_TEST_DB_3). Add database role db_owner for read / write access.

sqlcmd -U sa -d TG_AIR_TEST_DB_1 -I -Q "CREATE USER junit FOR LOGIN junit"
sqlcmd -U sa -d TG_AIR_TEST_DB_1 -I -Q "EXEC sp_addrolemember 'db_owner', 'junit'"
  1. Execute script to create the required SP sp_generate_inserts (from ttgams-dao/src/main/resources/sql/sp_generate_inserts.sql)

  2. Execute tests with MsSql driven testing profile -- mvn clean compile test -PsqlServer-User1 (use mvn clean test -PsqlServer-User1 -DfailIfNoTests=false -Dtest=fielden.analysis.reliability.ReReliabilityTest to run single test.)

Clone this wiki locally