testcase

abstract test case using python unittest

我的未来我决定 提交于 2019-11-30 10:53:48
问题 Is it possible to create an abstract TestCase , that will have some test_* methods, but this TestCase won't be called and those methods will only be used in subclasses? I think I am going to have one abstract TestCase in my test suite and it will be subclassed for a few different implementation of a single interface. This is why all test methods are the some, only one, internal method changes. How can I do it in elegant way? 回答1: I didn't quite understand what do you plan to do -- the rule of

how to add dozen of test cases to a test suite automatically in python

ぃ、小莉子 提交于 2019-11-30 06:59:38
问题 i have dozen of test cases in different folders. In the root directory there is a test runner. unittest\ package1\ test1.py test2.py package2\ test3.py test4.py testrunner.py Currently I added the four test cases manually into a test suite import unittest from package1.test1 import Test1 from package1.test2 import Test2 from package2.test3 import Test3 from package2.test4 import Test4 suite = unittest.TestSuite() suite.addTests(unittest.makeSuite(Test1)) suite.addTests(unittest.makeSuite

Junit test case for database insert method with DAO and web service

醉酒当歌 提交于 2019-11-30 00:53:26
I am implementing a webservice based university management system. This system adds certain courses to database. here below is the code that I am using. Course.java public class Course { private String courseName; private String location; private String courseId; public String getCourseId() { return courseId; } public void setCourseId(String courseId) { this.courseId = courseId; } public String getCourseName() { return courseName; } public void setCourseName(String courseName) { this.courseName = courseName; } public String getLocation() { return location; } public void setLocation(String

abstract test case using python unittest

耗尽温柔 提交于 2019-11-29 22:49:43
Is it possible to create an abstract TestCase , that will have some test_* methods, but this TestCase won't be called and those methods will only be used in subclasses? I think I am going to have one abstract TestCase in my test suite and it will be subclassed for a few different implementation of a single interface. This is why all test methods are the some, only one, internal method changes. How can I do it in elegant way? I didn't quite understand what do you plan to do -- the rule of thumb is "not to be smart with tests" - just have them there, plain written. But to achieve what you want,

Writing a re-usable (parametrized) unittest.TestCase method [duplicate]

↘锁芯ラ 提交于 2019-11-29 20:58:12
Possible Duplicate: How to generate dynamic (parametrized) unit tests in python? I'm writing tests using the unittest package, and I want to avoid repeated code. I am going to carry out a number of tests which all require a very similar method, but with only one value different each time. A simplistic and useless example would be: class ExampleTestCase(unittest.TestCase): def test_1(self): self.assertEqual(self.somevalue, 1) def test_2(self): self.assertEqual(self.somevalue, 2) def test_3(self): self.assertEqual(self.somevalue, 3) def test_4(self): self.assertEqual(self.somevalue, 4) Is there

Restart failed test case automatically in TestNG/Selenium

心已入冬 提交于 2019-11-29 20:57:56
问题 I am using Selenium webdriver, in Java with TestNG to run an X amount of test cases. What I would like, is for any test case to automatically restart (either from starting or from point of failure), as soon as it fails. I know TestNG framework has the following method @Override public void onTestFailure(ITestResult tr) { log("F"); } but I do not know how to find out which testcase it was and then how would I restart it. 回答1: I wanted to see an example with actual code in it and found it here:

how to add dozen of test cases to a test suite automatically in python

丶灬走出姿态 提交于 2019-11-28 23:53:05
i have dozen of test cases in different folders. In the root directory there is a test runner. unittest\ package1\ test1.py test2.py package2\ test3.py test4.py testrunner.py Currently I added the four test cases manually into a test suite import unittest from package1.test1 import Test1 from package1.test2 import Test2 from package2.test3 import Test3 from package2.test4 import Test4 suite = unittest.TestSuite() suite.addTests(unittest.makeSuite(Test1)) suite.addTests(unittest.makeSuite(Test2)) suite.addTests(unittest.makeSuite(Test3)) suite.addTests(unittest.makeSuite(Test4)) result =

java.lang.NoClassDefFoundError:android and junit test

你说的曾经没有我的故事 提交于 2019-11-28 22:40:41
I saw that I'm not the only one having this problem but I don't find a correct answer. I have an android project that I want to test. I create a junit test class for each class of my project. My problem is when I run my test, I have the following error : java.lang.NoClassDefFoundError: android/content/Context This is my class test : public class DevicesBDDTest extends TestCase { DevicesBDD bdd; /** * @throws java.lang.Exception */ protected static void setUpBeforeClass() throws Exception { } /** * @throws java.lang.Exception */ protected static void tearDownAfterClass() throws Exception { }

How do I put new List<int> {1} in an NUNIT TestCase?

跟風遠走 提交于 2019-11-28 21:08:35
I have the method: public static int Add(List<int> numbers) { if (numbers == null || numbers.Count == 0) return 0; if (numbers.Count == 1) return numbers[0]; throw new NotImplementedException(); } Here is my test against it, but it does not like new List<int> {1} in the TestCase: [TestCase(new List<int>{1}, 1)] public void Add_WithOneNumber_ReturnsNumber(List<int> numbers) { var result = CalculatorLibrary.CalculatorFunctions.Add(numbers); Assert.AreEqual(1, result); } It gives me the error: An attribute argument must be a constant expression, typeof expression or array creation expression of

Writing a re-usable (parametrized) unittest.TestCase method [duplicate]

被刻印的时光 ゝ 提交于 2019-11-28 17:10:29
问题 Possible Duplicate: How to generate dynamic (parametrized) unit tests in python? I'm writing tests using the unittest package, and I want to avoid repeated code. I am going to carry out a number of tests which all require a very similar method, but with only one value different each time. A simplistic and useless example would be: class ExampleTestCase(unittest.TestCase): def test_1(self): self.assertEqual(self.somevalue, 1) def test_2(self): self.assertEqual(self.somevalue, 2) def test_3