gdx-setup icon indicating copy to clipboard operation
gdx-setup copied to clipboard

include unit test in project template

Open keturn opened this issue 6 years ago • 5 comments

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.

keturn avatar Dec 09 '18 03:12 keturn

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

czyzby avatar Dec 09 '18 08:12 czyzby

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

keturn avatar Dec 09 '18 19:12 keturn

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

czyzby avatar Dec 09 '18 19:12 czyzby

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. :heavy_check_mark:

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

keturn avatar Dec 10 '18 03:12 keturn

Removing those two

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

czyzby avatar Dec 10 '18 05:12 czyzby