Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests should export logs in order to improve pipeline integration #222

Open
CarlosSMA opened this issue Jan 5, 2022 · 1 comment
Open

Comments

@CarlosSMA
Copy link

Problem

I've cloned this repo and am using it in GitLab due to its CI/CD options (clone: https://gitlab.com/CarlosSMA/flask-base).

While doing the process, I've noticed that the tests done in the manage.py file don't export artifact logs in JUnit, and thus the GitLab pipeline can't show what tests were made, and their respective status and duration.

For now, I've implemented the xmlrunner lib in the test() function, however this doesn't seem to be the best solution, and I'd like to avoid using news libs.

Temporary fix

The following code is available on the feat-tests branch:

  • requirements.txt
[...]
urllib3==1.25.8
webassets==0.12.1
Werkzeug==0.15.5
WTForms==2.2.1
xmlrunner==1.7.7
  • manage.py
@manager.command
def test():
    """Run the unit tests."""
    import unittest
    import xmlrunner
    
    test_results = xmlrunner.XMLTestRunner(output="tests-reports", outsuffix='log',).run(unittest.TestLoader().discover("tests"))
  • .gitlab-ci.yml
[...]
job_test:
  stage: test
  tags:
  - test
  script:
  - python3 manage.py test
  artifacts:
    when: always
    reports:
      junit:
      - tests-reports/TEST-test_basics.BasicsTestCase-log.xml
      - tests-reports/TEST-test_user_model.UserModelTestCase-log.xml
@abhisuri97
Copy link
Contributor

Can you make a pull request for this. I'll merge it in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants