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.

Because most of classes and methods in Kotlin are final by default. So we need to mark all provide methods as open to use with DaggerMock. It’s really a noise.

Mockito 2 already support mock Kotlin class without open keyword. I wonder if we can do something similar with DaggerMock?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:30 (24 by maintainers)

github_iconTop GitHub Comments

1reaction
PaulWoitaschekcommented, Jun 15, 2017

You can use the annotation to annotate annotations.

@Target(AnnotationTarget.ANNOTATION_CLASS)
annotation class AllOpen

Then you can use another annotation you use to mark your classes and simply not apply the AllOpen to that class in release builds.

So your debug/java/src/main...will be

@AllOpen
@Target(AnnotationTarget.CLASS)
annotation class OpenForTesting

And your release/java/src/main...will be

@Target(AnnotationTarget.CLASS)
annotation class OpenForTesting

That way in release builds everything stays final, if that is the concern.

0reactions
lenguyenthanhcommented, Jul 4, 2017

Great, Thanks @fabioCollini.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Kotlin Programming Language
Gradle. Gradle is introducing Kotlin as a language for writing build scripts ; Corda. Corda is an open-source distributed ledger platform, supported by...
Read more >
Kotlin and Android | Android Developers
Android Studio provides first-class support for Kotlin. It even has built-in tools to help you convert Java-based code to Kotlin. The Show Kotlin...
Read more >
Kotlin (programming language) - Wikipedia
Kotlin has support for the web; by compiling to JavaScript (i.e., Kotlin/JS with the classic back-end, is declared stable since version 1.3), while...
Read more >
48. Kotlin support - Spring
Spring Boot provides Kotlin support by leveraging the support in other Spring projects such as Spring Framework, Spring Data, and Reactor.
Read more >
Announcing Kotlin support for protocol buffers
We're excited to deepen our investment in the Kotlin language with official support for Kotlin in the open source Protocol Buffers project.
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