Unit Testing with MS SQL Server (based on TG Air project) - fieldenms/tg GitHub Wiki
- 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>
-
Create database
logininstance named junit as per expectations inttgams-dao/src/main/java/fielden/test_config/SqlServerDomainDrivenTestCaseRunner.java -
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)
-
Create database
userfrom junitlogininstance in each database (i.e. TG_AIR_TEST_DB_1, TG_AIR_TEST_DB_2, TG_AIR_TEST_DB_3). Add database roledb_ownerfor 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'"-
Execute script to create the required SP
sp_generate_inserts(fromttgams-dao/src/main/resources/sql/sp_generate_inserts.sql) -
Execute tests with
MsSqldriven testing profile --mvn clean compile test -PsqlServer-User1(usemvn clean test -PsqlServer-User1 -DfailIfNoTests=false -Dtest=fielden.analysis.reliability.ReReliabilityTestto run single test.)