开发者

TestNG @Factory: Debugging test classes seems impossible to do

开发者 https://www.devze.com 2023-02-15 18:10 出处:网络
I\'m having trouble debugging test classes when using TestNG Factories. It seems like, when in Debug mode, you can only debug as far as the factory class.

I'm having trouble debugging test classes when using TestNG Factories. It seems like, when in Debug mode, you can only debug as far as the factory class.

In the following example, it's possible to debug in WebTestFactory and impossible in WebTest.

Factory class:

public class WebTestFactory {
  @Factory
  public Object[] createInstances() {
   Object[] result = new Object[10]; 
   for (int i = 0; i < 10; i++) {
      result[i] = new WebTest(i * 10);
    return result;
  }
}

Test class:

public class WebTest {

  // **** BREAKPOINTS IMPOSSIBLE HERE ****

  private int m_numberOfTimes;
  public WebTest(int numberOfTimes) {
    m_numberOfTimes = numberOfTimes;
  }

  @Test
  public void testServer() {
   for (int i = 0; i < m_numberOfTimes; i++) {

    }
  }
}

EDIT: Additional info: My current project struc开发者_C百科ture is that the test class and the factory are in different projects. The Factory is in the project from which I run my tests, and the test class is in an external jar.

EDIT: It's not a TestNG problem. Just Eclipse going crazy again!


I really doubt TestNG has anything to do with your problem: Java code is Java code, if Eclipse can run it, Eclipse can debug it. The fact that the code is in a different jar or a different project makes no difference. What might make a difference is if tests are running in a different process, but I doubt it's the case here.

There are a number of reasons why Eclipse wouldn't let you put a break point somewhere, I suggest you Google the topic and report back here.

0

精彩评论

暂无评论...
验证码 换一张
取 消