TestRunner: run testcase suite

This commit is contained in:
debugtalk
2017-06-21 18:43:15 +08:00
parent 1965a7ddce
commit fc7ded4046
3 changed files with 25 additions and 26 deletions

View File

@@ -1,7 +1,7 @@
import os
import random
import requests
from ate import runner, exception
from ate import runner, exception, utils
from .base import ApiServerUnittest
class TestUtils(ApiServerUnittest):
@@ -15,31 +15,9 @@ class TestUtils(ApiServerUnittest):
return requests.delete(url)
def test_run_single_testcase_success(self):
testcase = {
"name": "create user which does not exist",
"request": {
"url": "http://127.0.0.1:5000/api/users/1000",
"method": "POST",
"headers": {
"content-type": "application/json"
},
"json": {
"name": "user1",
"password": "123456"
}
},
"response": {
"status_code": 201,
"headers": {
"Content-Type": "application/json"
},
"body": {
'success': True,
'msg': 'user created successfully.'
}
}
}
success, _ = self.test_runner.run_single_testcase(testcase)
testcase_file_path = os.path.join(os.getcwd(), 'test/data/demo.json')
testcases = utils.load_testcases(testcase_file_path)
success, _ = self.test_runner.run_single_testcase(testcases[0])
self.assertTrue(success)
def test_run_single_testcase_fail(self):
@@ -90,3 +68,10 @@ class TestUtils(ApiServerUnittest):
}
}
)
def test_run_testcase_suite_success(self):
testcase_file_path = os.path.join(os.getcwd(), 'test/data/demo.json')
testcases = utils.load_testcases(testcase_file_path)
result = self.test_runner.run_testcase_suite(testcases)
self.assertEqual(len(result), 2)
self.assertEqual(result, [(True, {}), (True, {})])