test automation principles

24
Test Automation and xUnit Author: Carlo Ibarra

Upload: netsuite

Post on 20-May-2015

3.787 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Test Automation Principles

Test Automation and xUnitTest Automation and xUnit

Author:Carlo Ibarra

Author:Carlo Ibarra

Page 2: Test Automation Principles

ScopeScope

Does not cover TDD.Test automation, principles and best practices.

xUnit basics.

Does not cover TDD.Test automation, principles and best practices.

xUnit basics.

Page 3: Test Automation Principles

TerminologyTerminology

SUT – system under test.

DOC – depended on component.

Fixture – preconditions to a test; everything a test needs to set up before assertion.

SUT – system under test.

DOC – depended on component.

Fixture – preconditions to a test; everything a test needs to set up before assertion.

Page 4: Test Automation Principles

Test AutomationTest Automation

“What I need is a list of specific unknown problems we will

encounter.”

- a Dilbert Quotes contest entry

Page 5: Test Automation Principles

Goals of Test AutomationGoals of Test Automation Tests should help us improve quality. Tests should help us improve quality.

Tests should help us understand the SUT. Tests should help us understand the SUT.

Tests should reduce (and not introduce) risks. Tests should reduce (and not introduce) risks.

Tests should be easy to run. Tests should be easy to run.

Tests should be easy to write. Tests should be easy to write.

Tests should require minimal maintenance as the system evolves around them. Tests should require minimal maintenance as the system evolves around them.

Page 6: Test Automation Principles

Four-Phase TestFour-Phase Test

1. Fixture Setup- test data, mocks, expected results constants

1. Fixture Setup- test data, mocks, expected results constants

2. Exercise SUT- Interact with the SUT to exercise desired behavior

2. Exercise SUT- Interact with the SUT to exercise desired behavior

3. Result Verification- Determine if expected outcome is obtained

3. Result Verification- Determine if expected outcome is obtained

4. Teardown- Restore state back to the state before testing

4. Teardown- Restore state back to the state before testing

Page 7: Test Automation Principles

The “Fragile Test” ProblemThe “Fragile Test” Problem

Behavior sensitivity- Change in requirements, functionality

Interface sensitivity- Change in UI

Data sensitivity- Change in source structures and state

Context sensitivity - Change in workflow or external DOCs

Behavior sensitivity- Change in requirements, functionality

Interface sensitivity- Change in UI

Data sensitivity- Change in source structures and state

Context sensitivity - Change in workflow or external DOCs

Page 8: Test Automation Principles

Principles of Test Automation

“Quality is free, but only to those

who are willing to pay heavily for it.”

- Lister, Demarco: “Peopleware”

Page 9: Test Automation Principles

Principle:

Write the Tests First.

Page 10: Test Automation Principles

Principle:

Use the Front Door First.

Page 11: Test Automation Principles

Principle:

Communicate Intent.

Page 12: Test Automation Principles

Principle:

Don’t Modify the SUT.

Page 13: Test Automation Principles

Principle:

Keep the Tests Independent.

Page 14: Test Automation Principles

Principle:

Isolate the SUT.

Page 15: Test Automation Principles

Principle:

Minimize Test Overlap.

Page 16: Test Automation Principles

Principle:

Minimize Untestable Code.

Page 17: Test Automation Principles

Principle:

Keep Test Logic Out of Production.

Page 18: Test Automation Principles

Principle:

Verify One Condition Per Test.

Page 19: Test Automation Principles

Principle:

Test Concerns Separately.

Page 20: Test Automation Principles

Principle:

Ensure Commensurate Effort

and Responsibility.

Page 21: Test Automation Principles

xUnit BasicsxUnit Basics

“In order to make an apple pie from scratch,you must first create the universe.”

- Carl Sagan

“In order to make an apple pie from scratch,you must first create the universe.”

- Carl Sagan

Page 22: Test Automation Principles

Introducing xUnitIntroducing xUnit Make it easy for developers to write test without

learning a new language.

Make it easy to test individual classes and objects without needing to have the rest of the application available.

Make it easy to run test or many test in a single action.

Minimize the cost of running tests so programmers aren’t discourage from running existing tests.

Make it easy for developers to write test without learning a new language.

Make it easy to test individual classes and objects without needing to have the rest of the application available.

Make it easy to run test or many test in a single action.

Minimize the cost of running tests so programmers aren’t discourage from running existing tests.

Page 23: Test Automation Principles

Common FeaturesCommon Features

Specify a test as a Test Method.

Specify the expected results within the test method in the form of calls to assertion methods.

Aggregate the tests into test suites that can be run as a single operation.

Run one or more tests to get a report on the results of a test run.

Specify a test as a Test Method.

Specify the expected results within the test method in the form of calls to assertion methods.

Aggregate the tests into test suites that can be run as a single operation.

Run one or more tests to get a report on the results of a test run.

Page 24: Test Automation Principles

Q&AQ&A