lundi 14 septembre 2020

Skip a testcase if the an argument is not in there test method - Python

In commands passing a param Ex: check

  • If the check is present in the test method then it will execute.
  • Here for one testmethod forgot to add that param and one is not required to execute that testmethod if the "check" param is there. Note:-
  1. Using python unitest
  2. If there is any new module lettme know.

sample code:

class some():
    def init():
        .......
        self.check = os.environ['check']

    def testmethod1():
        if self.check:
            ........

    def testmethod2():
          ......   
    
    def testmethod3():
        if self.check:
            .........

    def testmethod4():
        ..........


in the above code, If self.check is true testmethod1, testmethod2, testmethod3 should execute. But is forgot to put check condition in testmethod2. In testmethod4 should not execute if slef.check is True but forgotten to put condition if not self.check.

  • So is there any way to skip one function and ran all testcases.

Thanks in Advance

Aucun commentaire:

Enregistrer un commentaire