Convert GUI Test Config into XOA
To converter Xena RFC GUI test configuration files into XOA RFC json format, you need to do the following steps.
Step 1. Create Project Folder
First, create a folder on your computer at a location you want. This folder will be the place where you keep your XOA RFC test suites and a simple Python program to load and run them using XOA RFC test framework.
Let’s create a folder called /my_xoa_project
/my_xoa_project
|
Step 2. Create Necessary Files
Create a main.py
file inside the folder /my_xoa_project
.
Then, on the same level as main.py
, create a folder /pluginlib
for keeping your test suites.
After that, create a __init__.py
inside folder /pluginlib
to make it into a package.
/my_xoa_project
|
|- main.py
|- /pluginlib
|- __init__.py
|
Step 3. Install XOA RFC Core
If you have already installed XOA RFC Core in your system, either to your global namespace or in a virtual environment, you can skip this step.
Step 4. Copy XOA RFC Test Suite Plugin into Project Folder
Copy a test suite plugin, e.g. /plugin2544
from XOA RFC Test Suite into /my_xoa_project/pluginlib
.
Copy your test configuration json
file, e.g. my2544_data.json
into /my_xoa_project
for easy access.
/my_xoa_project
|
|- main.py
|- my2544_data.json
|- /pluginlib
|- __init__.py
|- /plugin2544
Step 5. Convert Test Config from Xena to XOA RFC
First, import xoa_core
and xoa_converter
into your Python code.
from xoa_core import controller
from xoa_converter.entry import converter
from xoa_converter.types import TestSuiteType
Then, to use the converter, you need the target schema for the old file to be converted into. After that, simply provide the target schema, the old config file to the converter function and get the new config file:
import asyncio
import json
from xoa_core import controller
from xoa_converter.entry import converter
from xoa_converter.types import TestSuiteType
# source config file to be converted
OLD_CONFIG_FILE = "my_old2544_config.v2544"
NEW_CONFIG_FILE = "xoa2544.json"
T_SUITE_NAME = "RFC-2544"
PLUGINS_PATH = "pluginlib"
async def start():
# create an instance of XOA rfc core controller
c = await controller.MainController()
# open and read xena test config my_old2544_config.v2544
with open(OLD_CONFIG_FILE) as f:
app_data = f.read()
# register rfc2544 plugin to core
c.register_lib(str(PLUGINS_PATH))
# get rfc2544 test suite information from the core's registration
info = c.get_test_suite_info(T_SUITE_NAME)
if not info:
print("Test suite is not recognized.")
return None
# convert the old config into new config
new_data = converter(TestSuiteType.RFC2544, app_data, info["schema"])
# save the new config file xoa2544.json
with open(NEW_CONFIG_FILE, "w") as f:
f.write(new_data)
# you can use the config file below to start the test
new_config = json.loads(new_data)
# Test suite name: "RFC-2544" is received from call of c.get_available_test_suites()
# test_id = c.start_test_suite(T_SUITE_NAME, new_config)
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.create_task(start())
loop.run_forever()