How to achieve before() and after() functionality in Test Complete
Is there an equivalent, or is there a way to achieve, before(), after(), beforeEach(), and afterEach() functionality available @ https://mochajs.org/#hooks?
I want to execute my tests in the sequence below:
Before:
OpenBrowser()
Login()
Tests:
Project1:
Test1
Test2
Project2:
Test1
Project3:
Test1
Test2
Test3
After:
Logout()
CloseBrowser()
Update:
I looked at Events > Test Engine Events > OnStartTest/OnStopTest, which is equivalent to beforeEach() and afterEach(). But could not find anything which is similar to before() and after() - execute steps once before all tests and once after all tests.
Hi,
As it was stated by Robert, TestComplete does not have means to execute some code at the start and end of the whole test run. You may try to emulate this in code. Consider this approach:
-- I assume that you are testing web application;
-- For web applications, the first step for almost any test is to get the reference to the tested web page via Page object provided by TestComplete;
-- You may implement a function in your test code that you will call from any place where you need to get a reference to the tested page. This function will try to find the page and return it if found. Otherwise it will resort to the browser start and site login sequence.