forked from budabum/cucumber-java-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalgorithm.txt
More file actions
104 lines (88 loc) · 3.53 KB
/
algorithm.txt
File metadata and controls
104 lines (88 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
Begining
Clone project
https://github.com/budabum/cucumber-java-skeleton
cd cucumber-java-skeleton
mvn test
Run idea
Import project from maven
Install cucumber plugin if not yet installed
Settings -> Plugins -> Browse plugin repository and type cucumber in search.
Install Cucumber for Java and agree to install dependant plugin.
Run belly.feature file (should fail)
Run RunCukesTest file (1 step passed and 2 ignored)
Evolution 1. Make test works
Copy autogenerated steps into Stepdefs.java
Run
Add code to make test passed
Change something in test scenario to make it failed (this is important!)
Evolution 2. API testing
git checkout tag/step1
open file api_test.feature
Run it and then RunCukeTests
Insert features and tags to run only needed scenarios
Replace
@CucumberOptions(plugin = {"pretty"})
with
@CucumberOptions(plugin = {"pretty"}, features = {"src/test/resources/skeleton/api_test.feature"})
Then add tag ‘@my’ to one of scenarios and into runner
@CucumberOptions(plugin = {"pretty"}, features = {"src/test/resources/skeleton/api_test.feature"}, tags=”@my”)
TASK: crate a couple more tests for one of these methods (see StringSteps)
Use http://docs.oracle.com/javase/7/docs/api/java/lang/String.html as requirements
Running test server
git checkout tag/step2
open new terminal or tab in terminal or use screen command line utility
run test server
ruby test-server.rb
Should start. Go to http://localhost:9944/ to check.
To install it in your environment do the following (already done in class)
Install ruby 1.9.3+
on ubuntu: sudo apt-get install ruby
for other OS use ruby documentation https://www.ruby-lang.org/en/downloads/ or better use http://rvm.io/
Install ‘sinatra’ web server
on linux: sudo gem install sinatra
on other OS, e.g. Windows: gem install sinatra
Shutdown test server (ctrl+c in its console)
Evolution 3. Rest testing.
git checkout tag/step3
run test server
look at file rest_test.feature - you can run it but it’ll not work (why???)
Set tags and run RunCukeTests - will work
Let’s look at steps: RestSteps
TASK: Create one more test for route /plus
http://localhost:9944/math/plus?a=2&b=3 -url spec for instance
TASK*: Create one more test for route /divide
http://localhost:9944/math/divide?a=9&b=3 -url spec for instance
Evolution 4. Rest testing continued.
git checkout tag/step4
restart test server
update maven dependencies in idea (if autoupdate is off)
let’s install postman (plugin for chrome/chromium)
run in postman
GET http://localhost:9944/users
POST http://localhost:9944/users/add
Content-Type: application/json
{"email":"user11@email.com", "firstName":"autotest", "lastName":"user"}
GET http://localhost:9944/users?email=user12@email.com
DELETE http://localhost:9944/users
look at file rest_test.feature - new scenario - get users with data table
look at file RestSteps - it has changed.
TASK: create a couple more tests for /users routes
Evolution 5. Web testing
git checkout tag/step5
restart test server
update maven dependencies in dea (if autoupdate is off)
look at file selenium_test.feature - run it (expected to fail)
look at SeleniumSteps.
Uncomment lines 74,75 and comment 73.
run test again - should pass
TASK: create one more test for any page
Rest testing
---------------
http://unirest.io/java.html
Postman rest client for chrome/chromium
Work with cucumber datatables
https://thomassundberg.wordpress.com/2014/06/30/cucumber-data-tables/
Scenario outlines
https://github.com/cucumber/cucumber/wiki/Scenario-Outlines
Other cucumber examples
https://github.com/cucumber/cucumber-jvm/tree/master/examples