On Github VineetReynolds / JUDCON-India-2013
A tour around the astrophysics lab
JUDCON India 2013
Vineet Reynolds L. P.
Red Hat
too hard > too slow > no time > no fun
The purpose of automated testing is to enable change. Verifying correctness is just a nice side-effect. - Jeremy Norris
So you can rule your code, not the bugs!
Extensible
&
Flexible
You typically need these...
Test as you usually do....
Or drive your development through stories/specifications...
You want to run your tests like they're in production, right?
No problems!
You can implement your own.
Selenium/WebDriver for functional black box tests
Target the ones your customers use.
What about HtmlUnit/PhantomJS?
Don't let your black box tests fool you
We're testing the UI and...
also performing state verification of 'testable' models or their substitutes.
So you don't fight your Data Access Layer
Test your database engine thoroughly as early as you can.
@Test @UsingDataSet("customer.xml") @ShouldMatchDataSet("customer-with-account.xml") public void testCreateAccountForCustomer() { // Setup. Query for a customer Customer customer = em.find(Customer.class, 1L); // Execute. Associate an account with the queried entity customerService.createAccount(customer); // Verify. Query for the updated customer // Avoid **this**, for REPEATABLE_READ/SERIALIZABLE em.flush(); em.clear(); Customer updatedCustomer = em.find(Customer.class, 1L); assertThat(updatedCustomer.getAccount(), equalTo(expectedAccount)); }
Far from it!