TestNG+Maven, how to run a block of code before calling the TestNG.xml using mvn test?

时间:2017-08-04 13:03:33

标签: maven testng

TestNG+Maven, I have a framework where a block of code generates the testNG.xml on runtime, so my problem is that when I execute the command - mvn test, it starts looking for the TestNG file which is still not there because the code to generate that TestNG.xml is yet not executed.

So I want to know an approach where whenever I execute mvn test, system should first execute a block of code (I already have that code which generates the TestNG.xml file) and pom.xml should pick the newly generated xml file and start running the test cases from newly generated testNG.xml.

1 个答案:

答案 0 :(得分:0)

You just need to create a .bat or .sh file. using these batch files you can trigger your first code and once it will complete the mvn command will be triggered.

below are some links which can help you to create a batch or sh file

https://fossbytes.com/what-is-a-batch-file-in-windows-how-to-create-a-batch-file/

https://askubuntu.com/questions/223691/how-do-i-create-a-script-file-for-terminal-commands/223698

Hope it will help you :)