question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception using new consumer version selector method in kotlin

See original GitHub issue

Hi,

I started to migrate the @Deprecated consumerVersionSelectors = [ ] in the @PactBroker annotation by the new way, using @PactBrokerConsumerVersionSelectors method like this. See bottom line:

image

However when running my PactTest that ran using commented-out code above, I get this exception:

image

I debugged a bit your library and figured, that this line tries to invoke the identified selectorsMethod with a testInstance param that is Optional.empty() though. I find it strange that invokeSelectorsMethod thinks my selector method has 1 param even though it doesn’t. This circumstance is explicitly handled in testClassHasSelectorsMethod:

image

  • Kotlin version: 1.7.10
  • Pact version: 4.3.13
  • junit5: yes, PactVerificationInvocationContextProvider

What else I tried:

  • Moving my selector method out of abstract class and into to concrete test class
  • Making it “kotlin static” leads to not running into my breakpoint in testClassHasSelectorsMethod even, because its not contained in testClass?.kotlin?.members:
companion object {
        @PactBrokerConsumerVersionSelectors
        @JvmStatic
        fun consumerVersionSelectors(): SelectorBuilder = SelectorBuilder().branch("my-branch")
    }

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:15 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
stefluhhcommented, Aug 12, 2022

Fix confirmed, this code works now:

@PactBrokerConsumerVersionSelectors
fun consumerVersionSelectors(): SelectorBuilder = SelectorBuilder()
     .branch("main")
     .environment("prod")
     .environment("qa")
     .environment("int")

Thanks a lot for this fast workflow, fix released just 3 days later, that’s amazing.

1reaction
stefluhhcommented, Aug 12, 2022

@viktorgt PACT has released the fix tonight.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Consumer Version Selectors | Pact Docs
Consumer version selectors are the (new) way to configure which pacts the provider verifies. Instead of providing a list of tag names (as...
Read more >
Releases · pact-foundation/pact-jvm - GitHub
Enables consumer driven contract testing, providing a mock service ... example JUnit4 Spring test using new consumer version selector method ...
Read more >
Exception - Android Developers
Unchecked exception thrown when an attempt is made to register a channel with a selector that was not created by the provider that...
Read more >
Understanding variant selection - Gradle User Manual
For all Ivy modules without variants, Gradle has a fallback selection method. Gradle does not perform variant aware resolution and instead selects either...
Read more >
Kotlin Language Documentation 1.7.21
New Kotlin K2 compiler for the JVM in Alpha ... Migration from an interface with constructor function to a ... Retrieve with selector....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found