In software programming, the module ETEST is used to verify the correct functionality of individual methods or algorithms of a program. ETEST is a white-box testing method, meaning that the source code to be verified is known when designing test cases and determining the expected results.
The procedure typically consists of 3 steps:
initializing the initial state
executing the operation that is to be tested
comparing the actual results with the expected results
The ETEST script driver performs the following tasks:
displaying test elements
searching particular tests
executing particular tests
Refer to the following example.
# Enable the new python 3 print syntax
from __future__ import print_function
# The path to the project
project_path = r"D:\PythonProjects\Example.project"
# Clean up any open project:
if projects.primary:
projects.primary.close()
# Load the project
proj = projects.open(project_path)
# Fetch the active application.
app = proj.active_application
# Create the online application for it.
onlineapp = online.create_online_application(app)
# Log in to the device.
onlineapp.login(OnlineChangeOption.Try, True)
# Start the application, if necessary.
if not onlineapp.application_state == ApplicationState.run:
onlineapp.start()
# Let the app do its work for some time...
system.delay(1000)
# This function runs the specified test/test series
def func_run_test(test_name):
print(test_name)
etest_test_provider.run_test(test_name)
while etest_test_provider.is_test_running:
system.delay(1000)
return
# Get all test series from the project
test_series = etest_test_provider.get_all_testseries()
# Run all test series
for test_object in test_series:
func_run_test(test_object)
# Get all test elements from test series "TS_MySeries"
test_elements = etest_test_provider.get_all_testelements("TS_MySeries")
if test_elements == None:
print ("No test series 'TS_MySeries' found")
else:
# Print all testelements
for test_element in test_elements:
print ("Found test element in Series TS_MySeries: " + test_element.Name)
# Run only "TS_Crank" test object
func_run_test(test_element.Name)
onlineapp.logout()
projects.primary.close()