Skip to content
Snippets Groups Projects
Commit fd8fafd0 authored by Philipp Schillinger's avatar Philipp Schillinger
Browse files

Always run all behavior check tests and print error message

parent a0643980
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,17 @@ ...@@ -2,6 +2,17 @@
import yaml import yaml
import unittest import unittest
def generate_test(test_type, test_data):
def test_method(self):
test_function = getattr(self, test_type)
if isinstance(test_data, list):
test_function(*test_data)
else:
test_function(test_data)
return test_method
class TestReport(unittest.TestCase): class TestReport(unittest.TestCase):
def test_report(self): def test_report(self):
...@@ -15,17 +26,20 @@ class TestReport(unittest.TestCase): ...@@ -15,17 +26,20 @@ class TestReport(unittest.TestCase):
if test_type == "assertTrue": if test_type == "assertTrue":
self.assertTrue(test_data, test_name) self.assertTrue(test_data, test_name)
def test_behavior_report(self):
if __name__ == '__main__':
try: try:
with open("/tmp/flexbe_app_behavior_report.log", 'r') as f: with open("/tmp/flexbe_app_behavior_report.log", 'r') as f:
report = yaml.safe_load(f) report = yaml.safe_load(f)
except IOError: except IOError:
return # skip test since there is no report to evaluate pass # add no tests because there is no report to evaluate
else:
for test_type, tests in report.items(): for test_type, tests in report.items():
for test_name, test_data in tests.items(): for test_name, test_data in tests.items():
if test_type == "assertTrue": function_name = "test_%s_%s" % (test_name, test_type)
self.assertTrue(test_data, test_name) test_function = generate_test(test_type, test_data)
test_function.__name__ = function_name
setattr(TestReport, function_name, test_function)
if __name__ == '__main__':
import rosunit import rosunit
rosunit.unitrun("flexbe_app", "test_report", TestReport) rosunit.unitrun("flexbe_app", "test_report", TestReport)
...@@ -15,7 +15,7 @@ CheckBehaviorsReport = new (function() { ...@@ -15,7 +15,7 @@ CheckBehaviorsReport = new (function() {
IO.BehaviorLoader.loadBehavior(m, function(error_string) { IO.BehaviorLoader.loadBehavior(m, function(error_string) {
console.log(error_string); console.log(error_string);
if (error_string != undefined) { if (error_string != undefined) {
report.assertTrue["behavior_"+behavior] = false; report.assertTrue["behavior_"+behavior] = [false, error_string];
console.log(behavior+" is false"); console.log(behavior+" is false");
} }
else{ else{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment