From ad8b52a136b4cf9feeed80b56f9a69026fc1db95 Mon Sep 17 00:00:00 2001 From: Carlos Mastalli <carlos.mastalli@laas.fr> Date: Mon, 16 Sep 2019 19:02:59 +0200 Subject: [PATCH] [unit-test] Fixed issue with multiple unit-tests + added solo unit-test --- unittest/test_load.py | 55 +++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/unittest/test_load.py b/unittest/test_load.py index f7e59df..a1783a6 100755 --- a/unittest/test_load.py +++ b/unittest/test_load.py @@ -1,5 +1,6 @@ #!/usr/bin/env python2 +import sys import unittest import example_robot_data @@ -21,6 +22,18 @@ class RobotTestCase(unittest.TestCase): self.assertTrue(hasattr(self.ROBOT, "q0"), "It doesn't have q0") +class HyQTest(RobotTestCase): + RobotTestCase.ROBOT = example_robot_data.loadHyQ() + RobotTestCase.NQ = 19 + RobotTestCase.NV = 18 + + +class TalosTest(RobotTestCase): + RobotTestCase.ROBOT = example_robot_data.loadTalos() + RobotTestCase.NQ = 39 + RobotTestCase.NV = 38 + + class TalosArmTest(RobotTestCase): RobotTestCase.ROBOT = example_robot_data.loadTalosArm() RobotTestCase.NQ = 7 @@ -33,20 +46,26 @@ class TalosArmFloatingTest(RobotTestCase): RobotTestCase.NV = 13 -class TalosTest(RobotTestCase): - RobotTestCase.ROBOT = example_robot_data.loadTalos() - RobotTestCase.NQ = 39 - RobotTestCase.NV = 38 - - class TalosLegsTest(RobotTestCase): RobotTestCase.ROBOT = example_robot_data.loadTalosLegs() RobotTestCase.NQ = 19 RobotTestCase.NV = 18 -class HyQTest(RobotTestCase): - RobotTestCase.ROBOT = example_robot_data.loadHyQ() +class ICubTest(RobotTestCase): + RobotTestCase.ROBOT = example_robot_data.loadICub(reduced=False) + RobotTestCase.NQ = 39 + RobotTestCase.NV = 38 + + +class SoloTest(RobotTestCase): + RobotTestCase.ROBOT = example_robot_data.loadSolo() + RobotTestCase.NQ = 15 + RobotTestCase.NV = 14 + + +class Solo12Test(RobotTestCase): + RobotTestCase.ROBOT = example_robot_data.loadSolo(False) RobotTestCase.NQ = 19 RobotTestCase.NV = 18 @@ -63,11 +82,17 @@ class TiagoNoHandTest(RobotTestCase): RobotTestCase.NV = 12 -class ICubTest(RobotTestCase): - RobotTestCase.ROBOT = example_robot_data.loadICub(reduced=False) - RobotTestCase.NQ = 39 - RobotTestCase.NV = 38 - - if __name__ == '__main__': - unittest.main() + test_classes_to_run = [ + HyQTest, TalosTest, TalosArmTest, TalosArmFloatingTest, TalosLegsTest, ICubTest, SoloTest, Solo12Test, + TiagoTest, TiagoNoHandTest + ] + loader = unittest.TestLoader() + suites_list = [] + for test_class in test_classes_to_run: + suite = loader.loadTestsFromTestCase(test_class) + suites_list.append(suite) + big_suite = unittest.TestSuite(suites_list) + runner = unittest.TextTestRunner() + results = runner.run(big_suite) + sys.exit(not results.wasSuccessful()) -- GitLab