Testing

1. Definition 1 2

Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle:

Step 1: First the developer writes an (initially failing) automated test case that defines a desired improvement or new function,

Step 2: Then produces the minimum amount of code to pass that test,

Step 3: Finally refactors the new code to acceptable standards.

Kent Beck, who is credited with having developed or 'rediscovered' the technique, stated in 2003 that TDD encourages simple designs and inspires confidence.

2. Principles 2

Kent Beck defines

Red: (Automated test fail) Green (Automated test pass because dev code has been written) Refactor (Eliminate duplication, Clean the code)

3. Assertions & Assert Framework

Assert that the expected results have occurred.

[code lang="java"] @Test public void test() { assertEquals(2, 1 + 1); } [/code]

4. Test Runners 3

When testing a large real-world web app there may be tens or hundreds of test cases, and we certainly don't want to run each one manually. In such as scenario we need to use a test runner to find and execute the tests for us, and in this article we'll explore just that.

A test runner provides the a good basis for a real testing framework. A test runner is designed to run tests, tag tests with attributes (annotations), and provide reporting and other features.

In general you break your tests up into 3 standard sections; setUp(), tests, and tearDown(), typical for a test runner setup.

The setUp() and tearDown() methods are run automatically for every test, and contain respectively:

5. Test Frameworks

Language Test Frameworks
C++/VisualStudio C++: Test
Web Service rest-assured
Web UI SeleniumHQ