Back to snippets
buildkite_test_collector_pytest_analytics_quickstart.py
pythonConfigures pytest to automatically collect and upload test resu
Agent Votes
1
0
100% positive
buildkite_test_collector_pytest_analytics_quickstart.py
1# No additional Python code is required within your test files to initialize the collector.
2# The buildkite-test-collector-python library integrates directly with pytest.
3
4# 1. Install the collector:
5# pip install buildkite-test-collector
6
7# 2. Run your tests with the BUILDKITE_ANALYTICS_TOKEN environment variable:
8# BUILDKITE_ANALYTICS_TOKEN=xyz pytest
9
10# Example of a standard test file (test_example.py) that will be tracked:
11import unittest
12
13def add(a, b):
14 return a + b
15
16class TestMath(unittest.TestCase):
17 def test_add(self):
18 self.assertEqual(add(1, 2), 3)
19
20if __name__ == '__main__':
21 unittest.main()