Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotations for test utils #746

Open
ChristoferAlexander opened this issue Nov 20, 2023 · 3 comments
Open

Annotations for test utils #746

ChristoferAlexander opened this issue Nov 20, 2023 · 3 comments
Labels

Comments

@ChristoferAlexander
Copy link
Contributor

ChristoferAlexander commented Nov 20, 2023

Is your feature request related to a problem? Please describe.

As proposed by @thoutbeckers here we could do with a test-annotations module on kaluga to gather all commonly used testing annotations.

Describe the solution you'd like

Create annotation for ignoring tests on JavaScript @IgnoreJs

/**
 * Ignore a test when running the test on a JavaScript test runtime.
 */
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
expect annotation class JsIgnore()

jsTest

// Map to Kotlin Ignore attribute so that the test is ignored by JavaScript test runtime.
actual typealias JsIgnore = kotlin.test.Ignore

Rest

// Nothing to do. This should only ignore tests on the JavaScript test runtime.
actual annotation class JsIgnore

Create similar annotations for Jvm and iOS.

Create annotation for running common tests as integration tests @IntegrationTEST

commonTest

/**
 * An annotation to indicate that the class represents an integration test.
 * The test is ignored if run as a unit test.
 */
expect annotation class IntegrationTest()

androidInstrumentedTest

@Retention
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CLASS)
actual annotation class IntegrationTest()

androidUnitTest

actual typealias IntegrationTest = org.junit.Ignore

iOSTest

@Retention
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CLASS)
actual annotation class IntegrationTest()

jsTest

@Retention
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CLASS)
actual annotation class IntegrationTest()
@ChristoferAlexander
Copy link
Contributor Author

@Daeda88 do you see any issues with having @IntegrationTEST in kaluga? Also what would be the process to have a common test run as an integration test on Android (Create the task and configure gradle)? I know iOS has no issues running integration tests as it anyway runs all tests on a sim.

@Daeda88
Copy link
Contributor

Daeda88 commented Nov 20, 2023

Problem is that when you write a library, you can only export the main libraries. That's a problem for Android where you don't have an instrumentationMain or anything. So it's difficult to make this work

@thoutbeckers
Copy link
Collaborator

That's a good point we didn't consider @Daeda88.

I suspect it can be done with the correct gradle module metadata but indeed a bit non-trivial to sort out.

The "easy" way is probably to manually specify dependencies for each sourceset, but then you might as well copy/paste the annotations to each sourceset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants