How to use extensionContext method of org.testcontainers.junit.jupiter.TestcontainersExtensionTests class

Best Testcontainers-java code snippet using org.testcontainers.junit.jupiter.TestcontainersExtensionTests.extensionContext

Source:TestcontainersExtensionTests.java Github

copy

Full Screen

...9public class TestcontainersExtensionTests {10 @Test11 void whenDisabledWithoutDockerAndDockerIsAvailableTestsAreEnabled() {12 ConditionEvaluationResult result = new TestTestcontainersExtension(true)13 .evaluateExecutionCondition(extensionContext(DisabledWithoutDocker.class));14 assertFalse(result.isDisabled());15 }16 @Test17 void whenDisabledWithoutDockerAndDockerIsUnavailableTestsAreDisabled() {18 ConditionEvaluationResult result = new TestTestcontainersExtension(false)19 .evaluateExecutionCondition(extensionContext(DisabledWithoutDocker.class));20 assertTrue(result.isDisabled());21 }22 @Test23 void whenEnabledWithoutDockerAndDockerIsAvailableTestsAreEnabled() {24 ConditionEvaluationResult result = new TestTestcontainersExtension(true)25 .evaluateExecutionCondition(extensionContext(EnabledWithoutDocker.class));26 assertFalse(result.isDisabled());27 }28 @Test29 void whenEnabledWithoutDockerAndDockerIsUnavailableTestsAreEnabled() {30 ConditionEvaluationResult result = new TestTestcontainersExtension(false)31 .evaluateExecutionCondition(extensionContext(EnabledWithoutDocker.class));32 assertFalse(result.isDisabled());33 }34 private ExtensionContext extensionContext(Class clazz) {35 ExtensionContext extensionContext = mock(ExtensionContext.class);36 when(extensionContext.getRequiredTestClass()).thenReturn(clazz);37 return extensionContext;38 }39 @Testcontainers(disabledWithoutDocker = true)40 static final class DisabledWithoutDocker {41 }42 @Testcontainers43 static final class EnabledWithoutDocker {44 }45 static final class TestTestcontainersExtension extends TestcontainersExtension {46 private final boolean dockerAvailable;47 private TestTestcontainersExtension(boolean dockerAvailable) {48 this.dockerAvailable = dockerAvailable;49 }50 boolean isDockerAvailable() {51 return dockerAvailable;...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Testcontainers-java automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in TestcontainersExtensionTests

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful