Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.quarkus.arc.deployment;

import org.jboss.jandex.DotName;

import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.runtime.LaunchMode;

public class TestsAsBeanDefiningAnnotationsProcessor {

@BuildStep
public void testsAsBeanDefiningAnnotations(LaunchModeBuildItem launchMode,
BuildProducer<BeanDefiningAnnotationBuildItem> producer) {
if (launchMode.getLaunchMode() != LaunchMode.TEST) {
return;
}

producer.produce(new BeanDefiningAnnotationBuildItem(DotName.createSimple("io.quarkus.test.junit.QuarkusTest")));
producer.produce(new BeanDefiningAnnotationBuildItem(DotName.createSimple("org.junit.runner.RunWith")));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.quarkus.example.arc;

import javax.enterprise.context.ApplicationScoped;

@ApplicationScoped
public class UnusedBean {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.quarkus.example.test;

import static org.junit.jupiter.api.Assertions.assertNotNull;

import javax.inject.Inject;

import org.junit.jupiter.api.Test;

import io.quarkus.example.arc.UnusedBean;
import io.quarkus.test.junit.QuarkusTest;

@QuarkusTest
class BeanOnlyInTestCase {

@Inject
UnusedBean unusedBean;

@Test
void assertBeanIsInjected() {
assertNotNull(unusedBean);
}
}