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.

Allow referencing the extension

See original GitHub issue

JUnit 5 has a neat extensions functionality which is not compatible with kotlintest even if it runs on JUnit framework. While the simple use cases in which we just need to log something can be handled by the TestListener, we cannot handle more advanced cases. In particular, how to interact with the extension (which seems reasonable and extremely useful)? Ideally, I would like to get a hold of the extension so I could query it.

In JUnit5 it would be (one of the options anyway)

@ExtendWith(MyExtension.class)
class Something() {

 @MyAnnotation
 MyType myType;

 @Test
 void doSomething() {
    myType.doSomething();
 }

}

In JUnit4 it would be even simpler

@Rule
MyRule myRule;

@Test
void fun() {
myRule.something();
}

This is useful for a variety of reasons:

  • Encapsulating resource mocks along with the sets of methods to interact with them (reset etc.)
  • Extracting common instantiation tasks hiding complexity from the tests - note that we could have handled it by a simple composition but then we would need to instantiate the object and later plug it into all of the lifecycle methods which is not ideal.
  • More

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kboomcommented, Nov 27, 2019

Thanks guys, it indeed works fine. It might not be directly apparent though so I would recommend enhancing the readme to make this pattern absolutely clear.

0reactions
sksamuelcommented, Nov 26, 2019

I don’t know if that’s the OP’s exact requirement. If it is then what you said would work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extension:Cite - MediaWiki
The Cite extension allows a user to create references as footnotes on a page. It adds two parser hooks to MediaWiki, ‎<ref> and...
Read more >
How to enable Reference Search View extension
Search @builtin references in the extension view to make sure you ... This should open the references sidebar with the reference results.
Read more >
10 Chrome extensions to help manage references, notes ...
Recommendations below cover tools for reference management, ... The extension also allows you to track down PDFs of the paper and export ...
Read more >
Referencing Extension
On first reference, use “NC State Extension.” On subsequent references, it's fine to condense the name to “Extension,” as long as it will...
Read more >
REFERENCE File Extension - ReviverSoft
The Budget In Brief Reference File is stored in the REFERENCE format and is affixed with the REFERENCE extension, and is used by...
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