cancel
Showing results for 
Search instead for 
Did you mean: 

How testcomplete works with scripts not being written inside the class?

SOLVED
Highlighted
Contributor

How testcomplete works with scripts not being written inside the class?

My question is if I have written my scripts using python. Let consider the below example

# example1.py

def test():

   print "hello world"

# example2.py

class sampletest:

      def test():

          print "hello world"

In the above examples, one being wriiten without class and other within class. I was surprised how testcomplete works with first example .

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: How testcomplete works with scripts not being written inside the class?

Keep in mind... this is Python SCRIPT, not full Python.  Not everything needs to have a class to be able to execute.  You can use classes, but they are not required for execution of functions.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
5 REPLIES 5

Re: How testcomplete works with scripts not being written inside the class?

This behavior is similar to a launching this code(e.g. in Python IDLE):

def test():
  print "hello world"
test()

but if you want to print the message in TestComplete, need to use: Log.Message("hello world")

Community Manager

Re: How testcomplete works with scripts not being written inside the class?

Hi @DKumar04,

 

Does IStaroverov's suggestion answer your question?

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
Contributor

Re: How testcomplete works with scripts not being written inside the class?

but my question is not about printing it's about how test complete works when there is no class but only routines inside .py script file?

Community Manager

Re: How testcomplete works with scripts not being written inside the class?

As far as I understand it works without the class. Do you have any errors?

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
Community Hero

Re: How testcomplete works with scripts not being written inside the class?

Keep in mind... this is Python SCRIPT, not full Python.  Not everything needs to have a class to be able to execute.  You can use classes, but they are not required for execution of functions.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
New Here?
Join us and watch the welcome video:
Watch the New Interview
APITestingMistake#2