简体   繁体   中英

TestNG with IntelliJ IDEA: How to use the testng.xml file in IntelliJ IDEA 9

I'm able to run TestNG unit tests in IntelliJ and see the pass/fail output in a window; this is without using any testng.xml file. I can also run the tests in the command-line using maven, ie mvn clean test -Dgroups=fast , and that works fine.

I've created a testng.xml file and added it to my project's directory, but it doesn't seem to have any effect.

How do I integrate the usage of a testng.xml file to define my test execution within IntelliJ IDEA 9?

1.Go to File->Settings-> Plugins>Verify that TestNG-J is enabled. 2.Configure the testNG xml file and provide it as an external source by going to edit configurations and selecting suite and providing the path of the testNG xml you created. 在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

1.Navigate to Run in the top menu
2.select the Run...
3.when the popup window get open go to the configuration
4.select test kind as suite
5.select the location of your xml file in Suite option 
6.click on run button your testng.xml file will run

在此处输入图片说明

Follow this link - http://www.jetbrains.com/idea/webhelp/run-debug-configuration-testng.html#config

There is an option just before the run icon that allows you to add the testng.xml file. In the run config dialog select the suite option. Then select the testng file. It worked for me.

Hope it helps.

Just Add this Plugin " Create TestNg XML "

& restart your Intellij IDE.

then :

  1. Right-Click on Your Project.
  2. Click on "Create TestNG XML" Image 1
  3. You will Get a Confirmation Dialog it will Show the Path Of Created XML File, Click "Ok". Image 2
  4. Again Right-Click on Your Project & then click "Synchronize 'Your Project Name'". Image 3
  5. You will find a newly created TestNG.xml file in your Project. Image 4

Follow the below steps:

  • Goto Intellij IDEA preferences ain search (command+,)
  • Search for plugins
  • Click on Marketplace
  • Search for testng
  • Install the plugin "Create TestNG XML" and Apply the changes
  • Restart Intellij
  • Right on your project and click on "Create TestNG XML"
  • Click OK on the confirmation dialog.
  • Expand the project folder and Voila , testng.xml will be created.

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