Skip to content

Commit 9dc559c

Browse files
authored
Begin writing about acceptance testing
1 parent 17f3c3e commit 9dc559c

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Start with Acceptance Testing
2+
3+
4+
Acceptance testing is where you should start before writing anything.
5+
Similarly, if in doubt, always check your acceptance tests and go from there.
6+
7+
Here, we're going to be describing something that looks like the A in [ATDD](https://en.wikipedia.org/wiki/Acceptance_test%E2%80%93driven_development), with [BDD](https://en.wikipedia.org/wiki/Behavior-driven_development) in the mix too.
8+
9+
## What is an acceptance test?
10+
11+
It is a high-level set of tests, written from the perspective of the user, showing clear steps through the step.
12+
13+
In BDD the behaviour of the system might be defined light so:
14+
15+
```cucumber
16+
Given the light is off
17+
When I turn the light on
18+
Then the light is on
19+
```
20+
21+
Here is the same Cumcumber script written as RSpec Ruby:
22+
23+
```ruby
24+
describe 'lighting' do
25+
let(:system) { LightingSystem.new }
26+
let(:create_light_use_case) { system.get_use_case(:create_light) }
27+
let(:turn_light_on_use_case) { system.get_use_case(:turn_light_on) }
28+
let(:view_light_status_use_case) { system.get_use_case(:view_light_status) }
29+
30+
let(:light_id) do
31+
response = create_light_use_case.execute
32+
response[:id]
33+
end
34+
35+
let(:view_light_status_response) do
36+
view_light_status_use_case.execute(light_id: light_id)
37+
end
38+
39+
context 'given the light is off' do
40+
it 'is off' do
41+
expect(view_light_status_response[:on]).to be(false)
42+
end
43+
44+
context 'when I turn the light on' do
45+
before { turn_light_on_use_case.execute(light_id: light_id) }
46+
47+
it 'is on' do
48+
expect(view_light_status_response[:on]).to be(true)
49+
end
50+
end
51+
end
52+
end
53+
```

0 commit comments

Comments
 (0)