pytest Infrastructure

This page explains how to execute pytest-based tests on Jenkins

Steps

  • Log into the Jenkins builder server

  • Install pytest on the builder server with following command:

    • pip install pytest==4.6.0 # 4.6.0 is the latest pytest version supporting Python 2

  • Git clone the target repo: https://github.com/changtengfei/demo_github_jenkins_repo

  • Create a folder in the root directory called “test“

  • Create a file called “test_dummy.py“ under “test“ folder

  • Write the test script following the document online at: http://pytest.org/en/latest/

    • Here is an example test script

      1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 import pytest import os def syscall(cmd): print '>>> {0}'.format(cmd) os.system(cmd) def test_compilation(): result = syscall("echo compilation...") assert result == None def test_bootload(): result = syscall("echo bootload...") assert result == None def test_communication(): result = syscall("echo communication...") assert result == None
  • Setup a Jenkins job (read https://crystalfree.atlassian.net/wiki/spaces/SCUM/pages/5341185), under “Build Step”, create a script and run command pytest

Related