Test Database Approaches
2. Local Database.
Shared Database
All Developers share a remote test database on the network. #1 Oracle DB.
Local Database
Each developer has their own copy of the database on their computer. #1 MySQL. #2 PostgreSQL.
Shared Database Pros
Shared Database Cons
Local Database Pros
Local Database Cons
Embedded Database
An in-memory database server is started and managed by test code and run inside the application. #1 SQLite. #2 Firebird SQL. #3 ScimoreDB. #4 Oracle Berkley DB.
Embedded Database Pros
Embedded Database Cons
Integration Testing
Is a broad category of tests that validate the integration between units of code or code and outside dependencies such as databases or network resources.
Integration tests characteristics
Integration tests should be:
Repeatable Integration test
If the test passes/fails on the first execution, it should pass/fail on the second execution if no code has changed.
Independent Integration test
A test should be able to be run on its own, independently of other tests, OR together with other tests, and have the same result either way.
Obvious Integration test
When a test fails, it should be as obvious as possible why it failed.
Integration Tests should NEVER use
Existing data
Integration Test Data Source
SingleConnectionDataSource - creates a direct connection without a connection pool, allowing steps to share the connection, and see changes being made by other steps.
Integration Test Life Cycle
@BeforeClass - runs once before all tests. Creates the DataSource and enables Transaction Scope (autocommit=false)
@Before - runs before each test for common Arrange steps
@Test - the test
@After - runs after each test. Rollback transaction
@AfterClass - runs once after all tests complete. Destroy the DataSource.