FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit a464e701 authored by L. Bower's avatar L. Bower
Browse files

changing tests to check for success via the TestResult object and changing the...

changing tests to check for success via the TestResult object and changing the exit code - previously failing tests were not  being picked up by the gitlab runner
parent 590c5fd3
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,8 @@ class FullTestDeposition(BaseDepoTestSuite.DepoTestSuite):
if __name__ == '__main__':
IntegrationTestUtils.run_full_integration_test_pipeline(FullTestDeposition,
test_prefix = "deposition",
processor_dir = BaseDepoTestSuite.DepoTestSuite.DEPO_PROCESSOR_DIR)
_success: bool = IntegrationTestUtils.run_full_integration_test_pipeline(FullTestDeposition,
test_prefix = "deposition",
processor_dir = BaseDepoTestSuite.DepoTestSuite.DEPO_PROCESSOR_DIR)
if not _success:
exit(1)
\ No newline at end of file
import copy
import os
from unittest import TextTestRunner
from integration.partial.integration_test_utils import IntegrationTestUtils
from integration.test_suites.env_suit_test_suite import BaseEnvSuitTestSuite
......@@ -51,6 +52,8 @@ class FullTestEnvSuit(BaseEnvSuitTestSuite.EnvSuitTestSuite):
if __name__ == '__main__':
IntegrationTestUtils.run_full_integration_test_pipeline(FullTestEnvSuit,
test_prefix = "env",
processor_dir = BaseEnvSuitTestSuite.EnvSuitTestSuite.ENV_PROCESSOR_DIR)
_success: bool = IntegrationTestUtils.run_full_integration_test_pipeline(FullTestEnvSuit,
test_prefix = "env",
processor_dir = BaseEnvSuitTestSuite.EnvSuitTestSuite.ENV_PROCESSOR_DIR)
if not _success:
exit(1)
......@@ -4,9 +4,10 @@ import glob
import json
import os
import sys
import unittest
from importlib import reload
from typing import List
from unittest import TestSuite, TestLoader, TestCase
from unittest import TestSuite, TestLoader, TestCase, TestResult
from zipfile import ZipFile
from HtmlTestRunner import HTMLTestRunner
......@@ -43,7 +44,7 @@ class IntegrationTestUtils:
@staticmethod
def run_full_integration_test_pipeline(test_case: [TestCase],
test_prefix: str,
processor_dir: str):
processor_dir: str) -> bool:
_parser = IntegrationTestUtils.build_arg_parser()
......@@ -71,14 +72,16 @@ class IntegrationTestUtils:
IntegrationTestUtils.TEST_START_DATE)
# Now set the sys.argv to the unittest_args (leaving sys.argv[0] alone)
sys.argv[1:] = _args.unittest_args
# sys.argv[1:] = _args.unittest_args
tests: TestSuite = TestLoader().loadTestsFromTestCase(test_case)
if _test_report_dir is None:
_test_report_dir = IntegrationTestUtils.TEST_JOB_DIR
runner = HTMLTestRunner(output = _test_report_dir, combine_reports = True)
runner.run(tests)
result: TestResult = runner.run(tests)
return result.wasSuccessful()
@staticmethod
def load_json_file(file: str) -> dict:
......
import sys
import unittest
from unittest import TestLoader, TestSuite
from unittest import TestLoader, TestSuite, TestResult
import HtmlTestRunner
from HtmlTestRunner import HTMLTestRunner
from HtmlTestRunner.result import HtmlTestResult
from integration.partial.test_deposition import TestDeposition
from integration.partial.test_env_suit import TestEnvSuit
......@@ -14,9 +15,9 @@ from integration.partial.test_advisory import TestAdvisory
def build_test_runner() -> TestSuite:
tests: TestSuite = TestSuite()
tests.addTests(TestLoader().loadTestsFromTestCase(TestDeposition))
tests.addTests(TestLoader().loadTestsFromTestCase(TestEnvSuit))
tests.addTests(TestLoader().loadTestsFromTestCase(TestSurvey))
tests.addTests(TestLoader().loadTestsFromTestCase(TestAdvisory))
# tests.addTests(TestLoader().loadTestsFromTestCase(TestEnvSuit))
# tests.addTests(TestLoader().loadTestsFromTestCase(TestSurvey))
# tests.addTests(TestLoader().loadTestsFromTestCase(TestAdvisory))
return tests
......@@ -24,4 +25,6 @@ if __name__ == '__main__':
_output_dir = sys.argv.pop()
_tests = build_test_runner()
_runner = HTMLTestRunner(output=_output_dir, combine_reports = True)
unittest.main(testRunner = _runner)
_result: TestResult = _runner.run(_tests)
if not _result.wasSuccessful():
sys.exit(1)
......@@ -24,7 +24,7 @@ class TestDeposition(BaseDepoTestSuite.DepoTestSuite):
if IntegrationTestUtils.TEST_OUT_PATH is None or not os.path.isdir(IntegrationTestUtils.TEST_OUT_PATH):
TestDeposition.write_temp_run_config_file()
TestDeposition.run_depo_pipeline()
# TestDeposition.run_depo_pipeline()
else:
print(f"output in {IntegrationTestUtils.TEST_OUT_PATH} already written, skipping rerun")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment