deltaspike-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Allen Cunningham <>
Subject Test-Control ProjectStage
Date Fri, 05 Dec 2014 20:25:53 GMT
I'm having trouble with the ProjectStage in Test-Control. My tests run with
ProjectStage.Production instead of UnitTest.

I put together a simple project to demonstrate my problem:

Test class:

@TestControl(startScopes = ApplicationScoped.class)
public class UnitTest {
  @Inject SampleClient sampleClient;

  @TestControl(projectStage = ProjectStage.UnitTest.class)
  public void go() {
    sampleClient.init(new StartupEvent());


public class SampleClient {
  @Inject SampleAPI sampleAPI;

  public void init(@Observes @Any StartupEvent event) {

The API:

public interface SampleAPI {
  public String doSomething();

The production implementation:

@Exclude(ifProjectStage = ProjectStage.UnitTest.class)
public class SampleImpl implements SampleAPI {

  public String doSomething() {
    return "Greetings from Impl";

And finally the mock bean:

@Exclude(exceptIfProjectStage = ProjectStage.UnitTest.class)
public class SampleMock implements SampleAPI {

  public String doSomething() {
    return "Greetings from Mock";

When I launch the app using CdiContainer, it loads the mock bean correctly,
but when I launch it using CdiTestRunner it loads SampleImpl.

Single stepping through OWB I see that the DeltaSpike ProjectStageProducer
sees projectStage == null and sets it to Production by default.

Am I missing something in my test config?

I put a zip of the project here:
Sorry it isn't Maven!
"ant" will launch it normally and "ant test" will run the unit test.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message