Skip to content
This repository has been archived by the owner on Mar 21, 2021. It is now read-only.

include unit test in project template #67

Open
keturn opened this issue Dec 9, 2018 · 5 comments
Open

include unit test in project template #67

keturn opened this issue Dec 9, 2018 · 5 comments

Comments

@keturn
Copy link

keturn commented Dec 9, 2018

The Kotlin / KTX templates have been useful in getting started!

Now I'm trying to write a unit test, and I'm having a heck of a time getting the tests to see the things in my core package. It'd help to have a test in the project template to show how it works.

Tests should be runnable both through IntelliJ's test runner as well as a gradle target.

@czyzby
Copy link
Owner

czyzby commented Dec 9, 2018

Why did you try so far? Putting your tests in src/test/kotlin should do the trick.

@keturn
Copy link
Author

keturn commented Dec 9, 2018

For example, I have core/src/test/kotlin/net.keturn.advent2018.gdx/Day06KtTest.kt intended to test core/src/main/kotlin/net/keturn/advent2018/gdx/Day06.kt, and IntelliJ doesn't show any errors while editing the test file, but when I click the Run Test button I get

Error:(6, 8) Kotlin: Unresolved reference: net

running gradlew test or gradlew core:test produces no such compiler failure, but there's also no message about that "expect false to be true" test I put in there either, so I'm not convinced that's running them either.

The problem may be that when I look at the project structure dialog, it thinks there is something named advent2018-gdx/core as well as just core and they're both pointing to the same sources and it doesn't like it. Is that something that was configured when I ran gradlew idea?

gdx-project-scopes

@czyzby
Copy link
Owner

czyzby commented Dec 9, 2018

You have dots in your folder name, replace this with actual folders.

@keturn
Copy link
Author

keturn commented Dec 10, 2018

Okay, I tried moving the test file to nested directories instead of one with dots, and that didn't seem sufficient to fix things.

Removing those two core and desktop entries from the project structure made it so that when I do Run Test from IntelliJ, they do now find the code in the package they're supposed to test. ✔️

Running gradlew test does build a core/build/reports/tests/test/index.html, but it reports 0 tests, 0 failures, 0 successes.

@czyzby
Copy link
Owner

czyzby commented Dec 10, 2018

Removing those two

It's weird they were included in the first place. How did you import the project?

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

No branches or pull requests

2 participants