Testing is all about verifying that something works as expected. What are the challenges then? There are many, one very obvious is to actually know how it should work. Another challenge is to isolate the system under test so that it is possible to know what is tested and determine if that specific part works as expected.
January 31, 2013
December 18, 2012
Test coverage – friend or foe?
Measuring the test coverage is something many people think is a good idea. But is it a good idea? It depends on the quality of the tests. Test coverage may be a good measurement if the tests are good. But suppose that we have a high degree of test coverage and bad tests?
I will show two examples of how to get a 100% test coverage using Cobertura. They will be based on a set of good tests and a set of bad tests.
How is test coverage calculated?
Test coverage is calculated by recording which lines of code that has been executed. If the code has been executed through a test in a testing framework then we have calculated the test coverage.
The calculation is done using these steps:
- Start with instrumenting compiled code
- Execute the instrumented code
- Each execution of a line is recorded in a log
- Combining this execution log with the source code enables us to calculate how many lines out of the total number of lines that has been executed
We will be able to say that 47% of the lines in the source code has been executed. If the execution is done through test code, this will give us a measurement of the test coverage.
September 28, 2012
Test drive an implementation using an Executable Specification – revisited
An example is perhaps the best way to describe something. Concrete examples are easier to understand than abstract descriptions.
I will show how Cucumber-JVM can be used to specify an example and how the example can be connected to the system under test, SUT. The example can then be executed using any IDE or using Maven.
September 3, 2012
Want change but don’t want to change
I have met several customers and potential customers that want to implement automated testing. They have been in very different areas; insurance, transport, telecom and so on.
One thing they have in common though, is that they want a change but they are reluctant to change.
July 8, 2012
Performing an action when a test fails
JUnit supports annotations so a method can be executed first in a test class or before each test method is executed. It also has annotations that supports methods to be executed after each test method or after the test class. This is very good if you need a common setup and a common tear down.
The after methods don’t give you access to the test result. You cannot know if a test method failed or not. This may pose a problem if you have a need to perform some specific actions after a failed test. A solution could be to implement an onError() method. But JUnit doesn’t support it.
A solution is to employ a @Rule annotation.
March 7, 2012
What is a good test?
A colleague asked that question the other day. What is a good test? It is a really difficult question to answer. There are a number of properties that hold true for a good test. I will list some of them and discuss why I think they are important. Others may think that the order of importance is different or that other properties are more important then those that I list.
I will show some examples using Java and JUnit of what I think are bad tests and how they can be refactored to something better.
Tests are automated in my world. I always try to avoid manually testing. The main reason for this is that manual testing is slow and hard to repeat arbitrary many times. Therefore, test should be read as automated test in for the rest of this text.
November 16, 2011
Testing a Web Service with SoapUI, JUnit, Maven and Cucumber
An example is perhaps the best way to describe something. Concrete examples are easier to understand then abstract descriptions.
I will show how SoapUI can be used to test a web service. I will also show three different tools that can be used to control SoapUI. This tool chain can easily be made a part of your continuous build.
October 31, 2011
Why separate test definitions from a driving JUnit class?
Why should the step definitions be separated from the driving JUnit class when using Cucumber for Java?
October 18, 2011
Testing a web application with Selenium 2
Selenium a great tool for testing web applications. The current version, Selenium 2, is a merge between Selenium and WebDriver. I will walk you through an example where we test a web site using Selenium in a few different ways. This is the same example as I demonstrated at Scandev on tour in Stockholm 18 October 2011.
September 16, 2011
Test drive an implementation using an Executable Specification
An example is perhaps the best way to describe something. Concrete examples are easier to understand then abstract descriptions.
I will show how Cucumber-JVM can be used to specify an example and how the example can be connected to the system under test, SUT. The example can then be executed using any IDE or using Maven.