Does Test Complete (SmartBear) can run unnitest classes in script steps?

Viewed 13

My query is if I can write scripts inside TestComplete using unittest?

As per TC (TestComplete) documentation it is possible to run unittest scripts --> https://support.smartbear.com/testcomplete/docs/working-with/integration/unit-test-frameworks/pyunit.html

However all examples explicitly involve UnitTest module. And I want to use Scripts module.

Simply put my intent is to automate desktop app using PageObjectModel pattern. I am aware that there are python libraries like PyAutoGUI but thing is application under test is a nightmarish mess. It is easier to handle it with help of TC since I gave it a try with PyAutoGui, Appium driver and Java and got stuck after just few elements. (AUT is mixing QT, java swing, java fx and browser locators (and propably some win wpf items too so easier to let TC handle it)

My idea is to:

  1. record some actions on the desktop,
  2. convert them to a script,
  3. pack them in classes respectively per window and/ or widget (like internal webbrowser),
  4. Use unittest test classes (inherit from unittest.TestCase) to run assertions in clean manner. => here is the problem.

Writing in TC things like that won`t work:

import unittest


class SimpleTest(unittest.TestCase):


    def foo(self):
        a = 'abc'
        b = 'abc'
        self.assertEqual(a, b)

    def bar(self):
        a = 'abc'
        b = 'def'
        self.assertEqual(a, b)  # I would be expecting to /
                                # TC throw an assertion exception here /
                                # but all I got is 'passed' in log


#if __name__='__main__' won`t work in TC
#if __name__ == '__main__': 
#    unittest.main() 

If I write that way it worked as "intended":

def foo():
    a = 'abc'
    b = 'abc'
    assert a == b

def bar():
    a = 'abc'
    b = 'def'
    assert a == b   #BOOM! FAILED
0 Answers
Related