Forum Discussion

shenyusun's avatar
shenyusun
Contributor
10 years ago
Solved

Any examples of using python to build your own class and add into test case?

Hello beautiful people,   Hope my question make sense here...   I've been using python to build a lot of test cases. I separated all my scripts into different categories, and import them when I ...
  • tristaanogre's avatar
    tristaanogre
    10 years ago

    Not python, but I use classes in a framework that I built.  Basically, for any given test scenario, there are a sequence of steps. Each step has an action and a set of parameters that inform that action.  I translate that into that I have a class for each test step. The class has properties that are the parameters needed to execute the step and validate the result. The class also has an "Execute" method which uses those properties to execute a bit of script code to perform the action.  Effectively, I have as many classes as I have distinct test step configurations.

     

    I then build an array of objects based upon these classes for the test scenario and then iterate through that array, calling the "Execute" method on each class.  

    Just one example... YMMV but I've seen a number of framework models that use something similar.  The tutorials for Selenium kind of walk through something similar.