Skip to content

Commit

Permalink
Allow @Container to be used as a meta-annotation (#6914)
Browse files Browse the repository at this point in the history
Fixes #6913
  • Loading branch information
eddumelendez committed Apr 11, 2023
1 parent 0bf52a9 commit 2525748
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Expand Up @@ -11,7 +11,7 @@
*
* @see Testcontainers
*/
@Target(ElementType.FIELD)
@Target({ ElementType.FIELD, ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)
public @interface Container {
}
@@ -0,0 +1,28 @@
package org.testcontainers.junit.jupiter;

import org.junit.jupiter.api.Test;
import org.testcontainers.containers.PostgreSQLContainer;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

import static org.assertj.core.api.Assertions.assertThat;

@Testcontainers
class MetaAnnotationTest {

@TcContainer
private static final PostgreSQLContainer<?> POSTGRESQL = new PostgreSQLContainer<>(
JUnitJupiterTestImages.POSTGRES_IMAGE
);

@Test
void test() {
assertThat(POSTGRESQL.isRunning()).isTrue();
}
}

@Container
@Retention(RetentionPolicy.RUNTIME)
@interface TcContainer {
}

0 comments on commit 2525748

Please sign in to comment.