??????????????? TestNG ??????????????????????????????????????????????й??????????????????????????????????????????????
???????????£?
import static org.testng.Assert.assertEquals;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
/**
* Created by fnngj on 2017/3/19.
*/
public class Demo {
// ???????????
@DataProvider(name = "data")
public Object[][] Users() {
return new Object[][] {
{ 1?? 1?? 2}??
{ 2?? 2?? 5}??
{ 3?? 3?? 6}??
};
}
@Test(dataProvider="data")
public void testAdd(int a??int b??int c) {
assertEquals(a + b?? c);
}
}
??????????? Python ???浥????????????????????? Python ????? unittest ?????????????????????????????????????????? HTML ???????????? ... ???????????????????????? unittest ??????????????????????????????????????????
????????в??????????????£???????????????????д??
import unittest
class TestAdd(unittest.TestCase):
def test_add_01(self):
self.assertEqual(1 + 2?? 3)
def test_add_02(self):
self.assertEqual(2 + 2?? 5)
def test_add_03(self):
self.assertEqual(3 + 3?? 6)
if __name__ == '__main__':
unittest.main()
????nose-parameterized ???????? Python ??????????????????????????????????????????

????GitHub ????? https://github.com/wolever/nose-parameterized
??????? unittest ?????? TestNG ???д???????
import unittest
from nose_parameterized import parameterized
class TestAdd(unittest.TestCase):
@parameterized.expand([
("01"??1?? 1?? 2)??
("02"??2?? 2?? 5)??
("03"??3?? 3?? 6)??
])
def test_add(self?? name?? a?? b?? c):
self.assertEqual(a + b?? c)
if __name__ == '__main__':
unittest.main(verbosity=2)
??????н????
????test_add_0_01 (__main__.TestAdd) ... ok
????test_add_1_02 (__main__.TestAdd) ... FAIL
????test_add_2_03 (__main__.TestAdd) ... ok
???????????κ???????????????????д????????????