Install unittest. (Python settings are omitted)
pip install unittest
test.py
import unittest
class TestTagAprioriMain(unittest.TestCase):
def setUp(self):
print('start')
def tearDown(self):
print('finished')
def test_success(self):
res = 1 + 2
self.assertEqual(res, 3)
def test_success2(self):
res = 1 + 2
self.assertEqual(res, 3)
def this_is_ignored(self):
res = 1 + 2
self.assertEqual(res, 1)
if __name__ == '__main__':
unittest.main()
Execution result
start
finished
.start
finished
.
----------------------------------------------------------------------
Ran 2 tests in 0.000s
OK
self.assertEqual ()
to check if the two are the same, but there are many others, so use the appropriate one.self.assertEqual()
self.assertTrue()
self.assertFalse()
There is also an error test, and you can write the error pattern concretely by writing as follows. (The one on the official page below is posted as it is)
s = 'hello world'
self.assertEqual(s.split(), ['hello', 'world'])
with self.assertRaises(TypeError):
s.split(2)
python3: https://docs.python.org/3/library/unittest.html python2.7: https://docs.python.org/2.7/library/unittest.html
https://jenkins.io/ jenkins is well known as a CI (Continuous Integration) tool. What is "continuous integration" just by looking at this? May be, but
Wikipedia:
http://e-words.jp/w/%E7%B6%99%E7%B6%9A%E7%9A%84%E3%82%A4%E3%83%B3%E3%83%86%E3%82%B0%E3%83%AC%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3.html :
In other words, if you think about it simply, it's like ** continuously passing through tests **. (Because the author doesn't fully understand it)
The image is something like "automatically, you can check that the test has passed regularly".
See other pages as we won't cover this time: https://appkitbox.com/knowledge/test/20121112-116
If you don't have the pyenv build wrapper, install it on Jenkins
numpy, pyyaml, pandas
Write the necessary variable settings and commands to run in the execute shell of Build. (The following may be included, but ...)
PYENV_HOME=$WORKSPACE/.pyenv/
export PYTHONPATH=$WORKSPACE:"$(dirname "$WORKSPACE")"
python setup.py test
That's it. After that, save your changes, build and make sure it's a success.
From the Job number, if you look at the Output Console, you can see the error just like a normal Terminal.
Recommended Posts