Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Custom runner delegate, "Notifications are not supported when all test-instances are created first" #660

@markkolich

Description

@markkolich

I'm trying to use PowerMockRunner with my own custom runner delegate that extends BlockJUnit4ClassRunner per the brief Wiki at https://github.com/jayway/powermock/wiki/JUnit_Delegating_Runner.

My custom runner delegate is simply this:

import org.junit.runners.BlockJUnit4ClassRunner;

public final class FooRunner extends BlockJUnit4ClassRunner {
  public FooRunner(final Class<?> klass) throws Exception {
    super(klass);
  }
  @Override
  public void run(final RunNotifier notifier) {
    super.run(notifier);
  }
}

And the corresponding unit test that makes use of my custom runner delegate with the @PowerMockRunnerDelegate annotation is this:

@RunWith(PowerMockRunner.class)
@PowerMockRunnerDelegate(FooRunner.class)
@PowerMockIgnore("javax.net.ssl.*")
public final class FooRunnerTestExample {
  public FooRunnerTestExample() {
    // Intentionally empty.
  }
  @Test
  public void fooTest() {
    // Intentionally empty.
  }
}

This runs fine, fooTest succeeds and test execution is funneled through my delegate.

However, in doing so, running with a delegate results in Powermock spewing these "errors" (warnings?) to System.err:

Notifications are not supported for behaviour ALL_TESTINSTANCES_ARE_CREATED_FIRST
Notifications are not supported for behaviour ALL_TESTINSTANCES_ARE_CREATED_FIRST
Notifications are not supported when all test-instances are created first!

There's no clear documentation on exactly what this means — further, I could be wrong, but in this use case I don't think this is a real problem that warrants complaints to System.err. In fact, using @PowerMockRunnerDelegate with Powermock's own org.powermock.modules.junit4.PowerMockRunnerDelegate.DefaultJUnitRunner results in the same System.err spew.

I conjecture the bug here is that these errors are mistakenly dumped to System.err given my use case. Even if this configuration is a "problem" there should at least be a way for Powermock users to suppress these messages.

I'm using JUnit 4.12 and Powermock 1.6.4.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions