def main(): test_classes_to_run = [TestOne] loader = unittest.TestLoader() suites_list = [] for test_class in test_classes_to_run: suite = loader.loadTestsFromTestCase(test_class) suites_list.append(suite) FullSuite = unittest.TestSuite(suites_list) dir = os.getcwd() outfile = open(dir + "\TestChromeSelenium.html", "w") runner = HTMLTestRunner(stream = outfile,title = 'Selenium',description = 'SeleniumTest') results = runner.run(FullSuite)
def main(): #unittest.main() test_classes_to_run = [TestMethod1] loader = unittest.TestLoader() suites_list = [] for test_class in test_classes_to_run: suite = loader.loadTestsFromTestCase(test_class) suites_list.append(suite) FullSuite = unittest.TestSuite(suites_list) dir = os.getcwd() outfile = open(dir + "\COMPortReport.html", "w") runner = HTMLTestRunner(stream = outfile,title = 'COM Port', description = 'COM Port test') results = runner.run(FullSuite)
def main(): test_classes_to_run = [TestOne] loader = unittest.TestLoader() suites_list = [] for test_class in test_classes_to_run: suite = loader.loadTestsFromTestCase(test_class) suites_list.append(suite) FullSuite = unittest.TestSuite(suites_list) dir = os.getcwd() outfile = open(dir + "\TestChromeSelenium.html", "w") runner = HTMLTestRunner(stream=outfile, title='Selenium', description='SeleniumTest') results = runner.run(FullSuite)
def main(): #unittest.main() test_classes_to_run = [TestMethod1] loader = unittest.TestLoader() suites_list = [] for test_class in test_classes_to_run: suite = loader.loadTestsFromTestCase(test_class) suites_list.append(suite) FullSuite = unittest.TestSuite(suites_list) dir = os.getcwd() outfile = open(dir + "\COMPortReport.html", "w") runner = HTMLTestRunner(stream=outfile, title='COM Port', description='COM Port test') results = runner.run(FullSuite)
assert 1 ser.write("US 1 2 162 \n") # Send a Value time.sleep(3) assert 1 ser.write("US 1 2 150 \n") # Send a Value time.sleep(3) assert 1 ser.write("US 1 1 0 \n") # Disconnect COM print("Disconnecting") assert 1 time.sleep(5) ser.close() print("Closing the Ports") assert 1 except Exception, e1: print "error communicating...: " + str(e1) else: print "cannot open serial port " ser.close() if __name__ == '__main__': suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestSerialPort)) dateTimeStamp = time.strftime('%Y%m%d_%H_%M_%S') buf = file("TestReport" + "_" + dateTimeStamp + ".html", 'wb') runner = HTMLTestRunner(stream=buf, title='Test Serial Port', description='Result of tests') runner.run(suite)
browser.type("q", "selenium RC") print "Enter the search test Selenium RC" browser.click("btnG") print "Click on Google Search button" browser.stop() @unittest.skipUnless(sys.platform.startswith("win"), "requires Windows") #@unittest.expectedFailure def test03_script(self): pass browser=self.selenium print "Open the google page" browser.type("q", "selenium RC") print "Enter the search test Selenium RC" browser.click("btnG") print "Click on Google Search button" browser.stop() def close_Chrome(self): self.driver.quit() #display.stop() if __name__ == '__main__': suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(main_script)) dateTimeStamp = time.strftime('%Y%m%d_%H_%M_%S') buf = file("TestSelenium" + "_" + dateTimeStamp + ".html", 'wb') runner = HTMLTestRunner(stream=buf,title='HTML Report',description='Result of tests') runner.run(suite)
def testNotEqual(self): self.failUnlessEqual(2, 3 - 2) class AlmostEqualTest(unittest.TestCase): def testNotAlmostEqual(self): self.failIfAlmostEqual(1.1, 3.3 - 2.0, places=1) def testAlmostEqual(self): self.failUnlessAlmostEqual(1.1, 3.3 - 2.0, places=0) if __name__ == '__main__': test_classes_to_run = [ OutcomesTest, TruthTest, EqualityTest, InequalityTest, AlmostEqualTest, ExceptionTest, FixturesTest ] loader = unittest.TestLoader() suites_list = [] for test_class in test_classes_to_run: suite = loader.loadTestsFromTestCase(test_class) suites_list.append(suite) FullSuite = unittest.TestSuite(suites_list) dir = os.getcwd() outfile = open(dir + "\UnitTest.html", "w") runner = HTMLTestRunner(stream=outfile, title='Test Unit test', description='Test') results = runner.run(FullSuite)
import unittest import datetime #http://stackoverflow.com/questions/5360833/how-to-run-multiple-classes-in-single-test-suite-in-python-unit-testing from HtmlTestRun import HTMLTestRunner from TestClassA import TestClassA from TestClassB import TestClassB from TestClassC import TestClassC if __name__ == '__main__': file_name = datetime.datetime.now().strftime("%Y_%m_%d_%H%M_HTML.html") output = open(file_name, "w") test_classes_to_run = [TestClassA, TestClassB, TestClassC] # Enter Classes Here loader = unittest.TestLoader() suites_list = [] for test_class in test_classes_to_run: suite = loader.loadTestsFromTestCase(test_class) suites_list.append(suite) big_suite = unittest.TestSuite(suites_list) runner = HTMLTestRunner(stream=output, verbosity=2, title="HTML Python Suite") runner.run(big_suite)
import unittest import datetime #http://stackoverflow.com/questions/5360833/how-to-run-multiple-classes-in-single-test-suite-in-python-unit-testing from HtmlTestRun import HTMLTestRunner from TestClassA import TestClassA from TestClassB import TestClassB from TestClassC import TestClassC if __name__ == '__main__': file_name = datetime.datetime.now().strftime("%Y_%m_%d_%H%M_HTML.html") output = open(file_name, "w") test_classes_to_run = [TestClassA, TestClassB, TestClassC] # Enter Classes Here loader = unittest.TestLoader() suites_list = [] for test_class in test_classes_to_run: suite = loader.loadTestsFromTestCase(test_class) suites_list.append(suite) big_suite = unittest.TestSuite(suites_list) runner = HTMLTestRunner(stream = output, verbosity = 2, title="HTML Python Suite") runner.run(big_suite)
class InequalityTest(unittest.TestCase): def testEqual(self): self.failIfEqual(1, 3-2) def testNotEqual(self): self.failUnlessEqual(2, 3-2) class AlmostEqualTest(unittest.TestCase): def testNotAlmostEqual(self): self.failIfAlmostEqual(1.1, 3.3-2.0, places=1) def testAlmostEqual(self): self.failUnlessAlmostEqual(1.1, 3.3-2.0, places=0) if __name__ == '__main__': test_classes_to_run = [OutcomesTest, TruthTest,EqualityTest,InequalityTest,AlmostEqualTest, ExceptionTest,FixturesTest] loader = unittest.TestLoader() suites_list = [] for test_class in test_classes_to_run: suite = loader.loadTestsFromTestCase(test_class) suites_list.append(suite) FullSuite = unittest.TestSuite(suites_list) dir = os.getcwd() outfile = open(dir + "\UnitTest.html", "w") runner = HTMLTestRunner(stream = outfile,title = 'Test Unit test',description = 'Test') results = runner.run(FullSuite)