-
Notifications
You must be signed in to change notification settings - Fork 1
101 lines (83 loc) · 2.85 KB
/
api_test_suite_3.yaml
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
101
name: api_Test_suite_3 # If there is a failed test in the test suite,
# the whole workflow will fail
on:
workflow_dispatch:
jobs:
happy_path_test:
name: Runs the Happy Path suite of tests
runs-on: ubuntu-latest
steps:
- name: checkout the repo
uses: actions/checkout@v3
- name: install latest nodejs
uses: actions/setup-node@v3
with:
check-latest: true
- name: Display the node version
run: node --version
- name: Install newman
run: npm install -g newman
- name: Display newman version
run: newman --version
- name: Run the test
continue-on-error: true
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
run: |
cd apiTest
pwd
newman run testHappyPath.postman_collection.json --env-var auth-url=${{ secrets.AUTH_URL }} --env-var api-url=${{secrets.API_URL}} --env-var auth_email=${{secrets.AUTH_EMAIL}} --env-var auth_pwd=${{secrets.AUTH_PWD}} > resultHappyApiTest.txt
- name: Upload results to artifacts
uses: actions/upload-artifact@v3
with:
name: resultHappyApiTest.txt
path: ./apiTest/resultHappyApiTest.txt
- name: Fail test if results include Failure
continue-on-error: false
run: |
cd apiTest
pwd
declare myString=`cat resultHappyApiTest.txt | grep failure`
if [[ ${#myString} -gt 0 ]]
then
exit 1
fi
unhappy_path_test:
name: Runs the Unhappy Path suite of tests
runs-on: ubuntu-latest
steps:
- name: checkout the repo
uses: actions/checkout@v3
- name: install latest nodejs
uses: actions/setup-node@v3
with:
check-latest: true
- name: Display the node version
run: node --version
- name: Install newman
run: npm install -g newman
- name: Display newman version
run: newman --version
- name: Run the test
continue-on-error: true
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
run: |
cd apiTest
pwd
newman run testUnhappyPath.postman_collection.json --env-var api-url=${{secrets.API_URL}} > resultUnhappyApiTest.txt
- name: Upload results to artifacts
uses: actions/upload-artifact@v3
with:
name: resultUnhappyApiTest.txt
path: ./apiTest/resultUnhappyApiTest.txt
- name: Fail test if results include Failure
continue-on-error: false
run: |
cd apiTest
pwd
declare myString=`cat resultUnhappyApiTest.txt | grep failure`
if [[ ${#myString} -gt 0 ]]
then
exit 1
fi