My query is if I can write scripts inside TestComplete using unittest? (Don`t get me wrong. Not import unittest/pytest test suite. WRITE tests in Scripts 'directory')
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 (could not click element due to level in duplicated object tree),
- Appium driver and Java which got stuck for hours 'trying' to click a single element
**(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:
record some actions on the desktop, convert them to a script, pack them in classes respectively per window and/ or widget (like internal webbrowser), 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