简体   繁体   English

在Intellij中调试TestNG时需要运行@BeforeSuite

[英]Need to run @BeforeSuite when debugging TestNG in Intellij

I am trying to debug a TestNG test in IntelliJ that is part of a test automation suite. 我正在尝试在IntelliJ中调试TestNG测试,它是测试自动化套件的一部分。 However, before this test can run, I need to run the code contained in the method marked @BeforeSuite. 但是,在运行此测试之前,我需要运行标记为@BeforeSuite的方法中包含的代码。

How can I configure IntelliJ to run the code in @BeforeSuite automatically when debugging a test? 调试测试时,如何配置IntelliJ在@BeforeSuite中自动运行代码?

If the method marked @BeforeSuite is in the same class then it will be automatically run first prior to your @Test methods. 如果标记为@BeforeSuite的方法在同一类中,则它将在您的@Test方法之前先自动运行。 You just need to keep the debug point in @BeforeSuite method. 您只需要将调试点保留在@BeforeSuite方法中。

Work around: 解决:

I found that I could specify to debug all tests in a "group". 我发现我可以指定调试“组”中的所有测试。 I can tag my @BeforeSuite class and my method under test with a group of "Debug". 我可以使用一组“调试”标记@BeforeSuite类和正在测试的方法。

Then In the Intellij run configuration, I tell it to run the "Debug" group. 然后,在Intellij运行配置中,我告诉它运行“ Debug”组。

Voila.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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