简体   繁体   中英

How to call test methods from my application?

I wrote Selenium tests (which I run with TestNG) for the webpage and would like to make a basic GUI. So basically, I would like to have a GUI with few checkboxes (to determine which tests should I run), "start" button and results of the tests - quite simple.

My problem is that I would like to somehow run tests when I click start in my GUI app and I am not sure if that is possible to do with TestNG (or any other testing framework). I know that I should write that code in the listener for the "start" button but I have no idea how to call tests.

The alternative idea is not to use any testing tools, basically just calling many methods which would return a boolean value if some test passed or not - which I don't think it's a smart idea.

From TestNG documentation:

TestListenerAdapter tla = new TestListenerAdapter();
TestNG testng = new TestNG();
testng.setTestClasses(new Class[] { Run2.class });
testng.addListener(tla);
testng.run();

Source: https://testng.org/doc/documentation-main.html#running-testng-programmatically

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM