Ask a Question

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

SOLVED
DKumar04
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
tristaanogre
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
[Hall of Fame]
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
Vegas Thrill Rider
Extensions available

View solution in original post

5 REPLIES 5
IStaroverov
Staff

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")

TanyaYatskovska
Community Manager

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

Hi @DKumar04,

 

Does IStaroverov's suggestion answer your question?

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
DKumar04
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?

TanyaYatskovska
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 Yatskovskaya
SmartBear Community and Education Manager


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
tristaanogre
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
[Hall of Fame]
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
Vegas Thrill Rider
Extensions available

View solution in original post

cancel
Showing results for 
Search instead for 
Did you mean: