Skip to content

Commit

Permalink
Enable test which works with Quarkus 3.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
holly-cummins committed Jul 31, 2024
1 parent 5fae411 commit 498e882
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void testThatTheTestsPassed() throws MavenInvocationException, FileNotFou

ContinuousTestingMavenTestUtils testingTestUtils = new ContinuousTestingMavenTestUtils();
ContinuousTestingMavenTestUtils.TestStatus results = testingTestUtils.waitForNextCompletion();
Assertions.assertEquals(6, results.getTestsPassed());
Assertions.assertEquals(7, results.getTestsPassed());
Assertions.assertEquals(0, results.getTestsFailed());

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void testThatTheTestsPassed() throws MavenInvocationException, FileNotFou
TestModeContinuousTestingMavenTestUtils testingTestUtils = new TestModeContinuousTestingMavenTestUtils(running);

ContinuousTestingMavenTestUtils.TestStatus results = testingTestUtils.waitForNextCompletion();
Assertions.assertEquals(6, results.getTestsPassed());
Assertions.assertEquals(7, results.getTestsPassed());
Assertions.assertEquals(0, results.getTestsFailed());

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
import java.util.HashMap;
import java.util.Map;

import jakarta.inject.Inject;

import org.eclipse.microprofile.rest.client.inject.RestClient;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

Expand All @@ -22,7 +23,6 @@
import io.quarkiverse.pact.consumer.testapp.Knitter;
import io.quarkiverse.pact.consumer.testapp.SheepService;
import io.quarkus.test.junit.QuarkusTest;
import jakarta.inject.Inject;

@ExtendWith(PactConsumerTestExt.class)
@PactTestFor(providerName = "farm", port = "8085")
Expand Down Expand Up @@ -82,9 +82,7 @@ public void testContractLooksCorrect() {
}

@Test
@Disabled // With Quarkus 3, test methods cannot directly access Pact classes, because they are in different classloaders. See https://github.com/quarkiverse/quarkus-pact/issues/73
// The good news is there are very few use cases where test code should be doing parameter injection of the mock server.
public void testPortIsCorrect(MockServer mockServer) {
public void testInjectionOfMockServer(MockServer mockServer) {
// If we have a test, pact assumes we will call it and validates there was a call
ConsumerAlpaca alpaca = sheepService.getByName("fluffy");
assertEquals(8085, mockServer.getPort()); // Testing the mock - don't do this normally!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void testThatTheTestsPassed() throws MavenInvocationException, IOExceptio
ContinuousTestingMavenTestUtils.TestStatus results = testingTestUtils.waitForNextCompletion();
// This is a bit brittle when we add tests, but failures are often so catastrophic they're not even reported as failures,
// so we need to check the pass count explicitly
Assertions.assertEquals(4, results.getTestsPassed());
Assertions.assertEquals(5, results.getTestsPassed());
Assertions.assertEquals(0, results.getTestsFailed());

// Now confirm a pact file got written by the pact consumer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void testThatTheTestsPassed() throws MavenInvocationException, IOExceptio
ContinuousTestingMavenTestUtils.TestStatus results = testingTestUtils.waitForNextCompletion();
// This is a bit brittle when we add tests, but failures are often so catastrophic they're not even reported as failures,
// so we need to check the pass count explicitly
Assertions.assertEquals(4, results.getTestsPassed());
Assertions.assertEquals(5, results.getTestsPassed());
Assertions.assertEquals(0, results.getTestsFailed());

// Now confirm a pact file got written by the pact consumer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
import java.util.HashMap;
import java.util.Map;

import jakarta.inject.Inject;

import org.eclipse.microprofile.rest.client.inject.RestClient;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

Expand All @@ -22,7 +23,6 @@
import io.quarkiverse.pact.testapp.ConsumerAlpaca;
import io.quarkiverse.pact.testapp.Knitter;
import io.quarkus.test.junit.QuarkusTest;
import jakarta.inject.Inject;

@ExtendWith(PactConsumerTestExt.class)
@PactTestFor(providerName = "farm", port = "8085")
Expand Down Expand Up @@ -82,9 +82,7 @@ public void testContractLooksCorrect() {
}

@Test
@Disabled // With Quarkus 3, test methods cannot directly access Pact classes, because they are in different classloaders. See https://github.com/quarkiverse/quarkus-pact/issues/73
// The good news is there are very few use cases where test code should be doing parameter injection of the mock server.
public void testPortIsCorrect(MockServer mockServer) {
public void testInjectionOfMockServer(MockServer mockServer) {
// If we have a test, pact assumes we will call it and validates there was a call
ConsumerAlpaca alpaca = alpacaService.getByName("fluffy");
assertEquals(8085, mockServer.getPort()); // Testing the mock - don't do this normally!
Expand Down

0 comments on commit 498e882

Please sign in to comment.