Acceptance test-driven development: Difference between revisions

Content deleted Content added
m Quercus solaris moved page Acceptance test-driven development to Acceptance test–driven development: en dash; development driven by acceptance tests, not "test-driven development of the acceptance type"
Adding short description: "Methodology in software development"
 
(39 intermediate revisions by 28 users not shown)
Line 1:
{{Short description|Methodology in software development}}
{{Software development process}}
 
'''Acceptance test-driventest–driven development''' ('''ATDD)''') is a [[Software development|development]] methodology based on communication between the business customers, the developers, and the testers.<ref name="Pugh11">{{cite book | first = Ken | last = Pugh | year = 2011 | title = Lean-Agile Acceptance Test-Driven Development: Better Software Through Collaboration | publisher = Addison-Wesley | isbn = 978-0321714084}}</ref> ATDD encompasses many of the same practices as [[Specificationspecification by example|Specification by Example]] (SBE),<ref>Adzic, Gojko. (2009) ''Bridging the Communication Gap: Specification by Example and Agile Acceptance Testing'', Neuri Limited,</ref><ref>{{cite book|last=Adzic|first=Gojko|authorlinkauthor-link=Gojko Adzic|title=Specification by example: How successful teams deliver the right software|publisher=Manning|year=2011|isbn=978-0-321-27865-4}}</ref> [[Behaviorbehavior-driven development|Behavior Driven Development]] (BDD),<ref>Chelimsky, David, Dave Astels, Zach Dennis, Aslak Hellesøy, Bryan Helmkamp, and Dan North. ''The RSpec Book: Behaviour Driven Development with RSpec, Cucumber, and Friends.'' The Pragmatic Bookshelf.</ref> Exampleexample-Drivendriven Developmentdevelopment (EDD),<ref>{{cite web| url = http://www.exampler.com/ | title = Example Driven Design| accessdateaccess-date = 2013-04-15}}
</ref> and Story Testsupport-Drivendriven Developmentdevelopment also called story test–driven development (SDD).<ref>{{cite web| url = http://industriallogic.com/papers/storytest.pdf | title = Story Test-Driven Development | accessdateaccess-date = 2013-04-15}}</ref> All these processes aid developers and testers in understanding the customer’scustomer's needs prior to implementation and allow customers to be able to converse in their own ___domain language.
 
ATDD is closely related to [[Testtest-driven development|Test-Driven Development]][ (TDD]).<ref>Beck, Kent. Test Driven Development: By Example. Addison-Wesley Professional, 2002.</ref> It differs by the emphasis on developer-tester-business customer collaboration. ATDD encompasses [[acceptance testing]], but highlights writing acceptance tests before developers begin coding.
 
== Overview ==
 
Acceptance tests are from the user’suser's point of view – the external view of the system.<ref name="Pugh11" /> They examine externally visible effects, such as specifying the correct output of a system given a particular input. Acceptance tests can verify how the state of something changes, such as an order that goes from “paid”"paid" to “shipped”"shipped". They also can check the interactions with interfaces of other systems, such as shared databases or web services. In general, they are implementation independent, although automation of them may not be.<ref>Melnik, Grigori, and Frank Maurer. {{cite webbook | url = http://www.springerlink.com/content/34w2q2561k471175/ | titlechapter = Multiple Perspectives on Executable Acceptance Test-Driven Development | accessdatedoi = 201310.1007/978-043-15540-73101-6_46 | title = Agile Processes in Software Engineering and Extreme Programming | series = Lecture Notes in Computer Science | year = 2007 | last1 = Melnik | first1 = Grigori | last2 = Maurer | first2 = Frank | volume = 4536 | pages = 245–249 | isbn = 978-3-540-73100-9 }}</ref><ref>Koskela, Lasse. (2007) Test Driven: TDD and Acceptance TDD for Java Developers. Manning Publications</ref>
 
=== Creation ===
 
Acceptance tests are created when the requirements are analyzed and prior to coding.<ref name="Pugh11" /> They can be developed collaboratively by requirement requester (product owner, business analyst, customer representative, etc.), developer, and tester. Developers implement the system using the acceptance tests. Failing tests provide quick feedback that the requirements are not being met. The tests are specified in business ___domain terms. The terms then form a ubiquitous language that is shared between the customers, developers, and testers.<ref>Evans, Eric. (2003) ''Domain-Driven Design: Tackling Complexity in the Heart of Software''. Addison-Wesley Professional.</ref> Tests and requirements are interrelated.<ref>{{cite book|last1=Weinberg|first1=Gerald|last2=Gause|first2=Donald|author-link=Gerald Weinberg|title=Exploring Requirements: Quality Before Design|publisher=Dorset House|year=1989|isbn=0-932633-13-7|url-access=registration|url=https://archive.org/details/exploringrequire00gaus}}</ref> A requirement that lacks a test may not be implemented properly. A test that does not refer to a requirement is an unneeded test. An acceptance test that is developed after implementation begins represents a new requirement.<ref>Martin, Robert C., and Grigori Melnik.{{cite web | url = http://www.gmelnik.com/papers/IEEE_Software_Moebius_GMelnik_RMartin.pdf | title = Tests and Requirements, Requirements and Tests: A Möbius Strip | access-date = 2013-04-15}}</ref>
<ref>{{cite book|last=Weinberg|first=Gerald|last2=Gause|first2=Donald|authorlink=Gerald_Weinberg|title=Exploring Requirements: Quality Before Design|publisher=Dorset House|year=1989|isbn= 0-932633-13-7}}</ref> A requirement that lacks a test may not be implemented properly. A test that does not refer to a requirement is an unneeded test. An acceptance test that is developed after implementation begins represents a new requirement.<ref>Martin, Robert C., and Grigori Melnik.{{cite web | url = http://www.gmelnik.com/papers/IEEE_Software_Moebius_GMelnik_RMartin.pdf | title = Tests and Requirements, Requirements and Tests: A Möbius Strip | accessdate = 2013-04-15}}</ref>
 
=== Testing Strategystrategy ===
 
Acceptance tests are a part of an overall testing strategy. They are the customer/user oriented tests that demonstrate the business intent of a system. ComponentDepending testson areyour technicaltest acceptancestrategy, testsyou developedmay byuse anthem architectin thatcombination specifywith theother behaviortest oftypes, large modulese.g. lower level Unit tests are created by the developer to drive easy-to-maintain code.,<ref>[Test-driven_development]</ref> They are often derived from acceptance tests and unit tests. Cross-functional testtesting includeincluding usability testing,<ref>Meszaros, Gerard, and Janice Aston. (2006) "Adding Usability Testing to an Agile Project." Agile Conference</ref> exploratory testing,<ref>{{cite web | title = Exploratory Testing Explained | date = 23 March 2019 | url = http://www.satisfice.com/articles/et-article.pdf }}</ref> and property testing (scaling and security).<ref>Meszaros, Gerard.(2007) ''xUnit Test Patterns: Refactoring Test Code''. Addison-Wesley.</ref>
 
== Acceptance criteria and tests ==
 
Acceptance criteria are a description of what would be checked by a test. Given a requirement such as “As"As a user, I want to check out a book from the library”library", an acceptance criterion might be, “Verify"verify the book is marked as checked out"." An acceptance test for this requirement gives the details so that the test can be run with the same effect each time.
 
=== Test format ===
 
===Test format===
Acceptance tests usually follow this form:<ref name="Pugh11" />
 
'''Given (setup)'''
 
: A specified state of a system
 
'''When (trigger)'''
:An action or event occurs
'''Then (verification)'''
:The state of the system has changed or an output has been produced
 
: An action or event occurs
For the example requirement, the steps could be listed as:
 
'''Given:Then (verification)'''
 
:Book that has not been checked out
: The state of the system has changed or an output has been produced
:User who is registered on the system
 
'''When:'''
Also, it is possible to add Statements that start with '''AND''' in any of the sections below (Given, When, Then).
:User checks out a book
 
'''Then:'''
For the example requirement, the steps could be listed as:<syntaxhighlight lang="cucumber">
:Book is marked as checked out
:Given Book that has not been checked out
:And User who is registered on the system
:When User checks out a book
:Then Book is marked as checked out
</syntaxhighlight>
 
=== Complete test ===
 
===Complete test===
The previous steps do not include any specific example data, so that is added to complete the test:
 
'''Given:'''
 
: Book that has not been checked out
 
{| class="wikitable"
|-
! Books
|
|-
| Title || Checked out
Line 58 ⟶ 66:
|}
 
: User who is registered on the system
 
{| class="wikitable"
|-
! Users
|-
| Name
|-
| Sam
|}
 
'''When:'''
 
: User checks out a book
 
{| class="wikitable"
Line 77 ⟶ 85:
! Checkout action
|-
| User || Sam || Checks out || Great book
|}
 
'''Then:'''
 
: Book is marked as checked out
 
{| class="wikitable"
Line 90 ⟶ 98:
| Title || Checked out || User
|-
| Great book || Yes || Sam
|}
 
=== Test examination ===
 
Examination of the test with specific data usually leads to many questions. For the sample, these might be:
 
* What if the book is already checked out?
* What if the book does not exist?
* What if the user is not registered on the system?
* Is there a date that the book is due to be checked-in?
* How many books can a user check out?
 
These questions help illuminate missing or ambiguous requirements. Additional details such as a due-date can be added to the expected result. Other acceptance tests can check that conditions such as attempting to check out a book that is already checked out produces the expected error.
 
=== Another test example ===
 
Suppose the business customer wanted a business rule that a user could only check out one book at a time. The following test would demonstrate that:
 
'''Scenario:'''
 
Check that checkout business rule is enforced
 
'''Given:'''
 
: Book that has been checked out
 
{| class="wikitable"
|-
! Books
|-
| Title || Checked out || User
Line 123 ⟶ 134:
| Another great book || No
|}
 
{| class="wikitable"
|-
! Users
|-
| Name
|-
| Sam
Line 134 ⟶ 146:
'''When:'''
 
: User checks out another book
 
{| class="wikitable"
Line 140 ⟶ 152:
! Checkout action
|-
| User || Sam || Checks out || Another great book
|}
 
'''Then:'''
 
: Error occurs
 
{| class="wikitable"
Line 157 ⟶ 169:
 
=== Project acceptance tests ===
 
In addition to acceptance tests for requirements, acceptance tests can be used on a project as a whole.<ref name="Pugh11" /> For example, if this requirement was part of a library book checkout project, there could be acceptance tests for the whole project. These are often termed [[SMART criteria|SMART objectives]]. An example test is "When the new library system is in production, the users will be able to check books in and out three times as fast as they do today".
 
Line 164 ⟶ 177:
* [[FitNesse]]
* [[Robot Framework]]
* [[Gauge (software)]]
* [[Cucumber (software)]]
 
== References ==
{{Reflist}}
 
== External links ==
 
* [http://acceptancetestdrivendevelopment.com Example of automation frameworks]
 
{{DEFAULTSORT:Acceptance test-driven development}}
 
[[Category:Software development philosophies]]