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 .

5 REPLIES 5
IStaroverov
SmartBear Alumni (Retired)

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
SmartBear Alumni (Retired)

Hi @DKumar04,

 

Does IStaroverov's suggestion answer your question?

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



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
SmartBear Alumni (Retired)

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

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



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
cancel
Showing results for 
Search instead for 
Did you mean: