python 노트 31: 테스트 보고서 생 성

          :1.HTMLTestRunner 2.nnreport
HTMLTestRunner.py python , C:\Users\fab\AppData\Local\Programs\Python\Python3
pip install nnreport
HTMLTestRunner

import unittest
import HTMLTestRunner

class Testlogin(unittest.TestCase):
    def test_login_normal(self):
        self.assertEqual(1,1)


    def test_login_black_list(self):
        self.assertTrue(False,'         ')
        #assertTrue        True,      True   
    def test_login_exit(self):
        self.assertNotIn(1,[1,2,3],'   not in  ')

    def test_login_max_count(self):
        self.assertNotEqual(1,2,'       ')


# unittest.main()              ,  HTMLTestRunner,   unittest.main()  
#   HTMLTestRunner      1:
suite = unittest.TestSuite()  #        
suite.addTest(Testlogin('test_login_max_count')) #          
suite.addTest(Testlogin('test_login_exit'))
#   HTMLTestRunner      2:
# suite1 = unittest.makeSuite(Testlogin)
#              ,          



f = open('    .html','wb')
#  'wb'                ,        
runner = HTMLTestRunner.HTMLTestRunner(f,title='        ',description='            ')
runner.run(suite)
# runner.run(suite1) #      
f.close()

다음은 Nreport 방식 으로 보고 합 니 다.
import unittest
import nnreport

class Testlogin(unittest.TestCase):
    def test_login_normal(self):
        '''    '''
        self.assertEqual(1,1)


    def test_login_black_list(self):
        '''     '''
        self.assertTrue(False,'         ')
        #assertTrue        True,      True   

    def test_login_exit(self):
        '''    '''
        self.assertNotIn(1,[1,2,3],'   not in  ')


    def test_login_max_count(self):
        '''     '''
        self.assertNotEqual(1,2,'       ')


#            ,nnreport   description    null,  :       ,          null

suite = unittest.makeSuite(Testlogin)
#              ,          

runner = nnreport.BeautifulReport(suite)
runner.report(description='        ',filename='log_in_report.html')

  


좋은 웹페이지 즐겨찾기