Skip to content

Commit ce208cf

Browse files
committed
Updated Jenkins to use pytest
1 parent de2aa4f commit ce208cf

File tree

9 files changed

+28
-29
lines changed

9 files changed

+28
-29
lines changed

jenkins/Languages.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Create a Jenkins job for popular programming languages
22
======================================================
33

4-
Jenkins can build and run code written in many languages, including C, C++, Fortran, Java, PHP and Python code, either directly or via automated build tools like Make or ANT. It can also run unit tests, for example written in CUnit, CppUnit, googletest, FRUIT, JUnit, PHPUnit or nosetests, and report on the success or failure of tests.
4+
Jenkins can build and run code written in many languages, including C, C++, Fortran, Java, PHP and Python code, either directly or via automated build tools like Make or ANT. It can also run unit tests, for example written for CUnit, CppUnit, googletest, FRUIT, JUnit, PHPUnit or pytest, and report on the success or failure of tests.
55

66
Create a Jenkins job
77
--------------------
@@ -67,7 +67,7 @@ phpunit --log-junit TestResults.xml --bootstrap src/autoload.php test/FibonacciT
6767
* Python
6868

6969
```
70-
nosetests --with-xunit
70+
py.test --junit-xml=report.xml
7171
```
7272

7373
For Java, Jenkins has in-built support for ANT:
@@ -96,7 +96,7 @@ For all languages:
9696
Publish test results
9797
--------------------
9898

99-
Jenkins can parse XML test results, in JUnit-compliant XML results file, and present test in a more useful, interactive way, that allows the test packages, classes, modules, classes, methods and functions to be browsed. Many test frameworks either output JUnit-compliant XML directly (e.g. googletest, FRUIT, JUnit, PHPUnit and nosetests) or in an XML format that can be converted into a JUnit-compliant XML results file (e.g. CUnit - our `make xunit-report` target does this conversion). CppUnit outputs an XML file, `TestResults.xml`, but this is not in xUnit-compliant XML format and a conversion does not, yet, exist.
99+
Jenkins can parse XML test results, in JUnit-compliant XML results file, and present test in a more useful, interactive way, that allows the test packages, classes, modules, classes, methods and functions to be browsed. Many test frameworks either output JUnit-compliant XML directly (e.g. googletest, FRUIT, JUnit, PHPUnit and pytest) or in an XML format that can be converted into a JUnit-compliant XML results file (e.g. CUnit - our `make xunit-report` target does this conversion). CppUnit outputs an XML file, `TestResults.xml`, but this is not in xUnit-compliant XML format and a conversion does not, yet, exist.
100100

101101
To instruct Jenkins to parse these result files
102102

@@ -110,7 +110,7 @@ To instruct Jenkins to parse these result files
110110
- Fortran: `result.xml`
111111
- Java: `build/test/xml/TESTS-TestSuites.xml`
112112
- PHP: `TestResults.xml`
113-
- Python: `nosetests.xml`
113+
- Python: `report.xml`
114114
* If you get a warning that your file `doesn't match anything` you can ignore this as the file hasn't been created yet.
115115
* Click Save.
116116
* Click Build Now.
@@ -139,7 +139,7 @@ How Jenkins behaves when there are errors
139139

140140
* This time the ball in the Build History table should be one of yellow or red.
141141
- C, Fortran and Java will show as yellow. Yellow means the build is unstable. Jenkins [defines](https://wiki.jenkins-ci.org/display/JENKINS/Terminology) a build as unstable if it was built successfully but a test result publisher has noted that a test has failed. This is because CUnit, FRUIT, and JUnit (invoked via ANT's `junit` task) returns an exit code of `0`, indicating success, Jenkins executes the post-build action to parse the test results file and so detects the test failures.
142-
- C++, PHP and Python will show as red. This means the build failed. This is because googletest, PHPUnit and nosetests return an exit code of `1` if any test fails.
142+
- C++, PHP and Python will show as red. This means the build failed. This is because googletest, PHPUnit and pytest return an exit code of `1` if any test fails.
143143
* Click the job link.
144144
* Click the Test Result link and you can browse to see the individual test functions that failed. Remember, too that the console output is always available via the Console Output link.
145145
* Click Back to project then Back to dashboard.

jenkins/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Install and deploy Jenkins
1515
Use Jenkins to run build-and-test jobs for various languages
1616
------------------------------------------------------------
1717

18-
Jenkins can build and run code written in many languages, including C, C++, Fortran, Java, PHP and Python code, either directly or via automated build tools like Make or ANT. It can also run unit tests, for example written in CUnit, CppUnit, googletest, FRUIT, JUnit, PHPUnit or nosetests, and report on the success or failure of tests.
18+
Jenkins can build and run code written in many languages, including C, C++, Fortran, Java, PHP and Python code, either directly or via automated build tools like Make or ANT. It can also run unit tests, for example written for CUnit, CppUnit, googletest, FRUIT, JUnit, PHPUnit or pytest, and report on the success or failure of tests.
1919

2020
* [Create a Jenkins job for popular programming languages](./Languages.md) including C, C++, Fortran, Java, PHP and Python.
2121

jenkins/VersionControl.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Run:
1515
```
1616
$ cp -r build_and_test_examples/python python-git
1717
$ cd python-git
18-
$ rm -f nosetests.xml *.pyc */*.pyc .gitignore
18+
$ rm -rf report.xml maths/*.pyc maths/tests/*.pyc maths/tests/__pycache__ .gitignore
1919
$ git init
2020
$ git config --global user.name "Your name"
2121
$ git config --global user.email [email protected]
@@ -26,7 +26,7 @@ $ git commit -m "Initial import" .
2626
Remove the current working files and set this repository to be a "bare" repository i.e. one with no current working copy:
2727

2828
```
29-
$ rm -rf __init__.py src/ README.md test/ xxx.md
29+
$ rm -rf README.md maths
3030
$ git config --bool core.bare true
3131
```
3232

@@ -44,7 +44,7 @@ Run:
4444
```
4545
$ cp -r build_and_test_examples/python python-mercurial
4646
$ cd python-mercurial
47-
$ rm -f nosetests.xml *.pyc */*.pyc .gitignore
47+
$ rm -rf report.xml maths/*.pyc maths/tests/*.pyc maths/tests/__pycache__ .gitignore
4848
$ hg init
4949
$ hg add .
5050
$ hg commit -m "Initial import" .
@@ -58,7 +58,7 @@ Run:
5858
$ svnadmin create $HOME/SVNROOT
5959
$ cp -r build_and_test_examples/python python
6060
$ cd python/
61-
$ rm -f nosetests.xml *.pyc */*.pyc .gitignore
61+
$ rm -rf report.xml maths/*.pyc maths/tests/*.pyc maths/tests/__pycache__ .gitignore
6262
$ svn import file://$HOME/SVNROOT/python -m "Initial import"
6363
```
6464

@@ -70,7 +70,7 @@ Run:
7070
$ cvs -d $HOME/CVSROOT init
7171
$ cp -r build_and_test_examples/python python
7272
$ cd python/
73-
$ rm -f nosetests.xml *.pyc */*.pyc .gitignore
73+
$ rm -rf report.xml maths/*.pyc maths/tests/*.pyc maths/tests/__pycache__ .gitignore
7474
$ cvs -d $HOME/CVSROOT import -m "Initial import" python vendor-tag release-tag
7575
```
7676

@@ -122,15 +122,15 @@ Check out the repository and runs tests
122122
- Modules Remote Name: `python`
123123
* Scroll down the page to under the Build heading.
124124
* Click Add build step and select Execute shell.
125-
* Enter the commands that run the tests using nosetests:
125+
* Enter the commands that run the tests using `py.test`:
126126

127127
```
128-
nosetests --with-xunit
128+
py.test --junit-xml=report.xml
129129
```
130130

131131
* Under the Post-build Actions heading, click Add post-build action.
132132
* Select Publish JUnit test result report.
133-
* In the Test report XMLs field enter the location of the test report XML file, `nosetests.xml`.
133+
* In the Test report XMLs field enter the location of the test report XML file, `report.xml`.
134134
* Click Save.
135135
* Click Build Now.
136136
* When the job completes, click on the job's link in the Build History table.

jenkins/examples/CVS job/config.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@
5252
<concurrentBuild>false</concurrentBuild>
5353
<builders>
5454
<hudson.tasks.Shell>
55-
<command>nosetests --with-xunit</command>
55+
<command>py.test --junit-xml=report.xml</command>
5656
</hudson.tasks.Shell>
5757
</builders>
5858
<publishers>
5959
<hudson.tasks.junit.JUnitResultArchiver plugin="[email protected]">
60-
<testResults>nosetests.xml</testResults>
60+
<testResults>report.xml</testResults>
6161
<keepLongStdio>false</keepLongStdio>
6262
<testDataPublishers/>
6363
<healthScaleFactor>1.0</healthScaleFactor>

jenkins/examples/Git job/config.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333
<concurrentBuild>false</concurrentBuild>
3434
<builders>
3535
<hudson.tasks.Shell>
36-
<command>nosetests --with-xunit</command>
36+
<command>py.test --junit-xml=report.xml</command>
3737
</hudson.tasks.Shell>
3838
</builders>
3939
<publishers>
4040
<hudson.tasks.junit.JUnitResultArchiver plugin="[email protected]">
41-
<testResults>nosetests.xml</testResults>
41+
<testResults>report.xml</testResults>
4242
<keepLongStdio>false</keepLongStdio>
4343
<testDataPublishers/>
4444
<healthScaleFactor>1.0</healthScaleFactor>

jenkins/examples/Mercurial job/config.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@
2626
<concurrentBuild>false</concurrentBuild>
2727
<builders>
2828
<hudson.tasks.Shell>
29-
<command>nosetests --with-xunit
30-
</command>
29+
<command>py.test --junit-xml=report.xml</command>
3130
</hudson.tasks.Shell>
3231
</builders>
3332
<publishers>
3433
<hudson.tasks.junit.JUnitResultArchiver plugin="[email protected]">
35-
<testResults>nosetests.xml</testResults>
34+
<testResults>report.xml</testResults>
3635
<keepLongStdio>false</keepLongStdio>
3736
<testDataPublishers/>
3837
<healthScaleFactor>1.0</healthScaleFactor>

jenkins/examples/Periodic job/config.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818
<customWorkspace>$HOME/build_and_test_examples/python</customWorkspace>
1919
<builders>
2020
<hudson.tasks.Shell>
21-
<command>nosetests --with-xunit</command>
21+
<command>py.test --junit-xml=report.xml</command>
2222
</hudson.tasks.Shell>
2323
</builders>
2424
<publishers>
2525
<hudson.tasks.junit.JUnitResultArchiver plugin="[email protected]">
26-
<testResults>nosetests.xml</testResults>
26+
<testResults>report.xml</testResults>
2727
<keepLongStdio>false</keepLongStdio>
2828
<testDataPublishers/>
2929
<healthScaleFactor>1.0</healthScaleFactor>
3030
</hudson.tasks.junit.JUnitResultArchiver>
3131
</publishers>
3232
<buildWrappers/>
33-
</project>
33+
</project>

jenkins/examples/Python job/config.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
<customWorkspace>$HOME/build_and_test_examples/python</customWorkspace>
1515
<builders>
1616
<hudson.tasks.Shell>
17-
<command>nosetests --with-xunit</command>
17+
<command>py.test --junit-xml=report.xml</command>
1818
</hudson.tasks.Shell>
1919
</builders>
2020
<publishers>
2121
<hudson.tasks.junit.JUnitResultArchiver plugin="[email protected]">
22-
<testResults>nosetests.xml</testResults>
22+
<testResults>report.xml</testResults>
2323
<keepLongStdio>false</keepLongStdio>
2424
<testDataPublishers/>
2525
<healthScaleFactor>1.0</healthScaleFactor>
2626
</hudson.tasks.junit.JUnitResultArchiver>
2727
</publishers>
2828
<buildWrappers/>
29-
</project>
29+
</project>

jenkins/examples/SVN job/config.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
<concurrentBuild>false</concurrentBuild>
3636
<builders>
3737
<hudson.tasks.Shell>
38-
<command>nosetests --with-xunit</command>
38+
<command>py.test --junit-xml=report.xml</command>
3939
</hudson.tasks.Shell>
4040
</builders>
4141
<publishers>
4242
<hudson.tasks.junit.JUnitResultArchiver plugin="[email protected]">
43-
<testResults>nosetests.xml</testResults>
43+
<testResults>report.xml</testResults>
4444
<keepLongStdio>false</keepLongStdio>
4545
<testDataPublishers/>
4646
<healthScaleFactor>1.0</healthScaleFactor>

0 commit comments

Comments
 (0)