Skip to content

Commit

Permalink
Allow @testcontainers to be inherited from superclass (#1843) (#2001)
Browse files Browse the repository at this point in the history
* Updated existing test with now expected behaviour
* @testcontainers is now @inherited
  • Loading branch information
bmuskalla authored and bsideup committed Oct 26, 2019
1 parent 43a76ab commit 92f0a4f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Expand Up @@ -3,6 +3,7 @@
import org.junit.jupiter.api.extension.ExtendWith;

import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
Expand All @@ -18,6 +19,10 @@
* last test method has executed. Containers declared as instance fields will
* be started and stopped for every test method.</p>
*
* <p>The annotation {@code @Testcontainers} can be used on a superclass in
* the test hierarchy as well. All subclasses will automatically inherit
* support for the extension.</p>
*
* <p><strong>Note:</strong> This extension has only be tested with sequential
* test execution. Using it with parallel test execution is unsupported and
* may have unintended side effects.</p>
Expand Down Expand Up @@ -52,6 +57,7 @@
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@ExtendWith(TestcontainersExtension.class)
@Inherited
public @interface Testcontainers {

/**
Expand Down
Expand Up @@ -3,8 +3,6 @@
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;

import java.util.concurrent.atomic.AtomicLong;

@Testcontainers
abstract class AbstractTestBase {

Expand Down
Expand Up @@ -6,7 +6,6 @@

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

@Testcontainers
class InheritedTests extends AbstractTestBase {

@Container
Expand Down

0 comments on commit 92f0a4f

Please sign in to comment.