feature/jenkinsfile
added parallel tests
This commit is contained in:
parent
707914f3ef
commit
2534a6413f
3 changed files with 106 additions and 32 deletions
46
Jenkinsfile
vendored
46
Jenkinsfile
vendored
|
@ -12,19 +12,43 @@ pipeline{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Test') {
|
stage('Test') {
|
||||||
agent {
|
|
||||||
docker {
|
parallel {
|
||||||
image 'qnib/pytest'
|
stage('on centos') {
|
||||||
|
agent {
|
||||||
|
docker {
|
||||||
|
image 'qnib/pytest'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
sh 'py.test --verbose --junit-xml test-reports/results.xml sources/test_calc.py || true'
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
junit 'test-reports/results.xml'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
stage('on debian') {
|
||||||
steps {
|
agent {
|
||||||
sh 'py.test --verbose --junit-xml test-reports/results.xml sources/test_calc.py || true'
|
docker {
|
||||||
}
|
image 'qnib/pytest'
|
||||||
post {
|
}
|
||||||
always {
|
}
|
||||||
junit 'test-reports/results.xml'
|
steps {
|
||||||
|
sh 'py.test --verbose --junit-xml test-reports/results.xml sources/test_calc2.py || true'
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
junit 'test-reports/results.xml'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
// steps {
|
||||||
|
// sh 'py.test --verbose --junit-xml test-reports/results.xml sources/test_calc.py || true'
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
stage('Deliver') {
|
stage('Deliver') {
|
||||||
agent {
|
agent {
|
||||||
|
|
|
@ -8,27 +8,27 @@ class TestCalc(unittest.TestCase):
|
||||||
# def test_fail(self):
|
# def test_fail(self):
|
||||||
# self.assertFalse(True, msg="This is failed test")
|
# self.assertFalse(True, msg="This is failed test")
|
||||||
|
|
||||||
def test_add_integers(self):
|
# def test_add_integers(self):
|
||||||
"""
|
# """
|
||||||
Test that the addition of two integers returns the correct total
|
# Test that the addition of two integers returns the correct total
|
||||||
"""
|
# """
|
||||||
result = calc.add2(1, 2)
|
# result = calc.add2(1, 2)
|
||||||
self.assertEqual(result, 3)
|
# self.assertEqual(result, 3)
|
||||||
|
#
|
||||||
def test_add_floats(self):
|
# def test_add_floats(self):
|
||||||
"""
|
# """
|
||||||
Test that the addition of two floats returns the correct result
|
# Test that the addition of two floats returns the correct result
|
||||||
"""
|
# """
|
||||||
result = calc.add2('10.5', 2)
|
# result = calc.add2('10.5', 2)
|
||||||
self.assertEqual(result, 12.5)
|
# self.assertEqual(result, 12.5)
|
||||||
|
#
|
||||||
def test_add_strings(self):
|
# def test_add_strings(self):
|
||||||
"""
|
# """
|
||||||
Test the addition of two strings returns the two strings as one
|
# Test the addition of two strings returns the two strings as one
|
||||||
concatenated string
|
# concatenated string
|
||||||
"""
|
# """
|
||||||
result = calc.add2('abc', 'def')
|
# result = calc.add2('abc', 'def')
|
||||||
self.assertEqual(result, 'abcdef')
|
# self.assertEqual(result, 'abcdef')
|
||||||
|
|
||||||
def test_add_string_and_integer(self):
|
def test_add_string_and_integer(self):
|
||||||
"""
|
"""
|
||||||
|
|
50
sources/test_calc2.py
Normal file
50
sources/test_calc2.py
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
import unittest
|
||||||
|
import calc
|
||||||
|
|
||||||
|
class TestCalc(unittest.TestCase):
|
||||||
|
"""
|
||||||
|
Test the add function from the calc library
|
||||||
|
"""
|
||||||
|
# def test_fail(self):
|
||||||
|
# self.assertFalse(True, msg="This is failed test")
|
||||||
|
|
||||||
|
def test_add_integers(self):
|
||||||
|
"""
|
||||||
|
Test that the addition of two integers returns the correct total
|
||||||
|
"""
|
||||||
|
result = calc.add2(1, 2)
|
||||||
|
self.assertEqual(result, 3)
|
||||||
|
|
||||||
|
def test_add_floats(self):
|
||||||
|
"""
|
||||||
|
Test that the addition of two floats returns the correct result
|
||||||
|
"""
|
||||||
|
result = calc.add2('10.5', 2)
|
||||||
|
self.assertEqual(result, 12.5)
|
||||||
|
|
||||||
|
def test_add_strings(self):
|
||||||
|
"""
|
||||||
|
Test the addition of two strings returns the two strings as one
|
||||||
|
concatenated string
|
||||||
|
"""
|
||||||
|
result = calc.add2('abc', 'def')
|
||||||
|
self.assertEqual(result, 'abcdef')
|
||||||
|
|
||||||
|
# def test_add_string_and_integer(self):
|
||||||
|
# """
|
||||||
|
# Test the addition of a string and an integer returns them as one
|
||||||
|
# concatenated string (in which the integer is converted to a string)
|
||||||
|
# """
|
||||||
|
# result = calc.add2('abc', 3)
|
||||||
|
# self.assertEqual(result, 'abc3')
|
||||||
|
#
|
||||||
|
# def test_add_string_and_number(self):
|
||||||
|
# """
|
||||||
|
# Test the addition of a string and a float returns them as one
|
||||||
|
# concatenated string (in which the float is converted to a string)
|
||||||
|
# """
|
||||||
|
# result = calc.add2('abc', '5.5')
|
||||||
|
# self.assertEqual(result, 'abc5.5')
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
Loading…
Reference in a new issue