Skip to content

Automatic Tests

Jennings Zhang edited this page Feb 3, 2021 · 2 revisions

Automated tests are a chore, however they are vital to software engineering.

This is not a guide on how to properly test your Python code, that is too big of a topic. Rather, here are three quick tips:

1. Adding Tests

Unit tests can be added to the {{ app_name }}/tests/test_*.py file.

2. Automatic Testing

Tests run automatically, and by default you get email notifications for failing tests.

2.1. Enforce Passing Tests

Taking it one step further, you can add needs: [test] under publish: to enforce passing tests as a precondition for automatic building and publishing of your ChRIS plugin.

github/workflows/ci.yml
@@ -34,6 +34,7 @@ jobs:
   publish:
     if: github.event_name == 'push' || github.event_name == 'release'
     runs-on: ubuntu-20.04
+    needs: [ test ]

2.2. Disable Automatic Testing

You can disable testing by adding (or uncommenting) the line if: false below test: in .github/workflows/ci.yml

github/workflows/ci.yml
@@ -22,7 +22,7 @@ on:
 jobs:
   test:
+    if: false
     runs-on: ubuntu-20.04
     steps:
       - uses: actions/checkout@v2