Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jmcnamara/pytest_c_testrunner
Using py.test as a testrunner for C unit test files
https://github.com/jmcnamara/pytest_c_testrunner
Last synced: 10 days ago
JSON representation
Using py.test as a testrunner for C unit test files
- Host: GitHub
- URL: https://github.com/jmcnamara/pytest_c_testrunner
- Owner: jmcnamara
- License: other
- Archived: true
- Created: 2014-02-04T01:40:12.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2017-06-27T10:03:46.000Z (over 7 years ago)
- Last Synced: 2024-08-01T10:17:16.814Z (3 months ago)
- Language: C
- Homepage: http://pytest-c-testrunner.readthedocs.org/
- Size: 368 KB
- Stars: 18
- Watchers: 4
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE.txt
Awesome Lists containing this project
README
## Using `pytest` as a testrunner for C unit test files
This is an simple tutorial on how to use the Python [`pytest`](http://pytest.org/latest/index.html) testing tool as a testrunner for C unit tests.
It includes [documentation](http://pytest-c-testrunner.readthedocs.org) and working examples.
![image](https://raw.github.com/jmcnamara/pytest_c_testrunner/master/docs/source/_images/output.png)
The tutorial shows how to extend pytest to collect C unit test files, execute them, capture the output and displays it.
$ sudo pip install pytest
$ make
$ py.test -v
========================= test session starts ==========================
platform darwin -- Python 2.7.2 -- py-1.4.20 -- pytest-2.5.2
collected 9 itemstest/test_basic_integers.c:13: test_some_integers() PASSED
test/test_basic_integers.c:14: test_some_integers() PASSED
test/test_basic_integers.c:19: test_more_integers() FAILED
test/test_basic_integers.c:20: test_more_integers() FAILED
test/test_basic_strings.c:16: test_some_strings() PASSED
test/test_basic_strings.c:17: test_some_strings() FAILED
test/test_basic_strings.c:25: test_more_strings() FAILED
test/test_basic_strings.c:26: test_more_strings() FAILED
test/test_basic_strings.c:27: test_more_strings() PASSED=============================== FAILURES ===============================
_________________________ test_more_integers() _________________________
Test failed : ASSERT_EQUAL_STR(313, 33) at test_basic_integers.c:19
got: 33
expected: 313_________________________ test_more_integers() _________________________
Test failed : ASSERT_EQUAL_STR(12, 2) at test_basic_integers.c:20
got: 2
expected: 12_________________________ test_some_strings() __________________________
Test failed : ASSERT_EQUAL_STR(foo, bar) at test_basic_strings.c:17
got: This is bar
expected: This is foo_________________________ test_more_strings() __________________________
Test failed : ASSERT_EQUAL_STR(bar, bar + 1) at test_basic_strings.c:25
got: his is bar
expected: This is bar_________________________ test_more_strings() __________________________
Test failed : ASSERT_EQUAL_STR(foo, NULL) at test_basic_strings.c:26
got: (null)
expected: This is foo================== 5 failed, 4 passed in 0.23 seconds ==================
[Read the full documentation](http://pytest-c-testrunner.readthedocs.org).