3. Wat iz test automation?
Tests are automated!
Tests could be run on developer laptop
Tests are running in CI on regular basis
Tests do not require network access
4. Signs that there is not
enough automation
Starting GUI to check backend changes
Deploying to server to check functionality
Relying on debug logging
Testing is for testers
You do not sleep well
21. Mockito Mocks
// Mocking all class dependencies
service = new WeatherServiceImpl();
service.weatherSource = Mockito.mock(WeatherSource.class);
// Sets-up mock reaction
when(service.weatherSource.findByCityName(eq("Kolka")))
.thenReturn(expectedResult);
// Your method under test here
// Verifies interactions with mock
verify(service.entityManager)
.persist(any(Temperature.class));
http://code.google.com/p/mockito/
30. Persistence Tests
Isolate and test all persistence
operations
Ideally all CRUD operations
Could be done in Generic way
31. In-memory Storage
Transient database for test execution
Some DBs have it built-in
For SQL DB mocking pick H2
Fast
Emulation modes
http://www.h2database.com/
34. Functional Tests
Not testing UI
Starting application context
Emulating multiple user requests
Persisting intermediate results
35. Web Client
REST API
Service Layer
Domain Model
ORM Integration Layer
Weather Other
SQL DB
REST API APIs
36. Embedded Container
Test should start application
It is possible to start embedded
CDI Container
EJB Container
Spring Container
37. Functional Testing using
Service Layer
Ignoring GUI data conversion
Easier to test
Faster test execution
38. Mock Integrations
Could be replaced using
Properties and factory beans
Spring @Profile
CDI @Alternative
Guice Modules
39. Environment Switch
Application should run in several modes
Done with System environment variable
Typical modes:
production
local deployment
embedded testing
41. Initial Data
Reset database after every test and
insert initial data
Reuse ORM mapping or other persistence
layer
Or use specialized tools like DbUnit