Continuous Integration & Automated Testing
Automated Testing
Automated testing is important as it allows us to easily test code quickly and repeatedly.
Unit Testing
This usually exercise all the methods in the public interface of an isolated, independent class.
- This verifies that a unit of code behaves as expected.
There is no strict definition for a unit, however it could be:
- A method in a class working in isolation.
- A flow of control when calling a method which covers a given set of paths.
- This is what you would use the cyclomatic count for.
- A class.
In object oriented programs, the unit test should be at least 1 class in isolation.
In Java you can use JUnit to write unit tests.
Integration Testing
Integration testing ensures that multiple units produce the correct output when they are working together.
You can also use JUnit to write integration tests.
Functional Testing
This ensures that the whole system behaves as expected.
This can also be called acceptance testing, to verify, for the customer, that the system is complete.
There is no universal acceptance testing tool as it depends heavily on what system you are developing.
Web Testing Frameworks
These are functional testing tools, specifically for web interfaces. You can:
- Make requests to an external website.
- Inspect the responses to ensure that they are correct.
There are several web testing frameworks:
- HTTPUnit
- Low level, simplistic, web API.
- Poor JavaScript support.
- HTMLUnit
- Better JavaScript support.
- Better document level support.
- JWebUnit
- A wrapper for HTMLUnit and Selenium.
These testing frameworks have the following issues:
- Can’t check if the web page actually works for the user.
- Limit on JavaScript testing.
-
Does not test browser compatibility.
This seems a bit silly.
Performance Testing
There are two main performance testing frameworks for Java:
- JUnitPerf:
- Does unit performance testing.
- It decorates existing JUnit tests so that they fail if running times are exceeded.
- JMeter:
- Provides functional performance testing:
- Can measure web server response times.
- Is site agnostic.
- Can’t run JavaScript.
- Provides functional performance testing:
Continuous Integration
This is the automatic process of building the complete system for ever commit. This has the advantages of:
- Allows the customer and test to see the progress.
- Integration bugs are reduced.
- Tests are run frequently.
- Reduces integration pain by doing it all the time.
Ant
Ant is a build tool for Java that makes:
- Building
- Environment Customisation
- Testing
- Deployment
possible in a single command that can be automated.