Forum Discussion

shenyusun's avatar
shenyusun
Contributor
9 years ago

Suggestion for better way to using TC with Python scripting

Hello beautiful people, 

 

I am new to TC, and I am using Python to create my testing script.

I would like to see if anyone can proivde me some feedback or better way to do my testing.

I am not sure if the way that I am doing is good for long term or if it's even the right way to use TC.

 

My strucutre looks like the example below:

 

Basic I have a project called Library. 

In that project, it contains two scripts:

1. Mouse_Script

2. Keyboard_Script.

 

Mouse_Script and Keyboard_Script contain a lot of functions. 

Example in Mouse_Script:

def mouse_rightClick()

  ...

def mouse_leftClick()

 ...

 

Example in Keyboard_Script:

def hit_enter()

 ...

def hit_control()

 ...

 

After that, I have another project called smoke_test.

It contains two scripts for example, one is called test_case1, and another one called test_case2.

Mouse_Script and Keyboard_Script are linked to Project smoke_test as reference, so that test_case1 and test_case2 can use the functions that's in the Library project.

 

test_case1 script looks like below:

 

import Mouse_Script

# testing mouse right click

Mouse_Script.mouse_rightClick()

 

 

test_case2 script looks like below:

 

import Keyboard_Script

# testing keyboard 'Enter' key

Keyboard_Script.hit_enter()

 

----------------------------------

 

I put test_case1 and test_case2 in the test organize section, and then run them if I want to a smoke test.

 

Is above set up a correct way to use TC do testing? Or is it a better way to do it or best practice?

 

Thank you guys!

Appreciate

 

  • What you have shown is perfectly OK in technical sense.

    But when come to best practice it means what best for your requirements.

     

    Each tester using TC for different test purpose and test should be designed according.

    So how you organize your classes libraries or name mappings would mostly depends on your situation.

    for me TC is flexible to used in different situations (at least most I have encountered)

    So you have to do some research what & how would be best for you.

     

    Having said that there are some general guidelines how TC would used in best way.

    Mainly how you organize name-mapping. Those are discussed over and over again in this forum  you can search and find.

     

    But if you have specific scenarios you would like to know how to tackle, forum could be able to help you.  

  • NisHera's avatar
    NisHera
    Valued Contributor

    What you have shown is perfectly OK in technical sense.

    But when come to best practice it means what best for your requirements.

     

    Each tester using TC for different test purpose and test should be designed according.

    So how you organize your classes libraries or name mappings would mostly depends on your situation.

    for me TC is flexible to used in different situations (at least most I have encountered)

    So you have to do some research what & how would be best for you.

     

    Having said that there are some general guidelines how TC would used in best way.

    Mainly how you organize name-mapping. Those are discussed over and over again in this forum  you can search and find.

     

    But if you have specific scenarios you would like to know how to tackle, forum could be able to help you.  

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Technically speaking, they don't need to be separate projects. You can add existing script units to any project. But your strategy sounds good. As was already said, what works for you works.

    The only thing I would suggest is to standardize the format of your test cases to make them have similar elements, like an assertion to check for pass/fail, logging code to mark begin/end of each test cae, etc.

    I'm partial to more data driven or Keyword based framework over the modular as, if your project gets large, you'll be maintaining a lot of code in a lot of different places but if this works for you, go for it.
  • Thanks guys! All the suggestion and feedback are very helpful!

    I'll continue to move forward with my TC journey