mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Junit5 tests: replace cryptic error with more obvious one
GitOrigin-RevId: 1573da1e431dec48b89a690bf1314f8e7e094cf7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
962b52d8a0
commit
ca59854526
@@ -1,8 +1,9 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.testFramework.junit5.fixture
|
||||
|
||||
import com.intellij.platform.util.coroutines.attachAsChildTo
|
||||
import com.intellij.platform.util.coroutines.childScope
|
||||
import com.intellij.testFramework.junit5.TestApplication
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
internal class TestFixtureImpl<T>(
|
||||
@@ -19,8 +20,12 @@ internal class TestFixtureImpl<T>(
|
||||
|
||||
override fun get(): T {
|
||||
try {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val deferred = _state as Deferred<ScopedValue<T>>
|
||||
@Suppress("UNCHECKED_CAST", "TestOnlyProblems")
|
||||
val deferred = _state as? Deferred<ScopedValue<T>> ?: error("""
|
||||
Fixture framework seems not be initialized. Make sure that:
|
||||
1. A test is written in Kotlin
|
||||
2. There is an annotation ${TestApplication::class.java.name} on top of your file.
|
||||
""".trimIndent())
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
return deferred.getCompleted().first
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.testFramework.junit5.fixture
|
||||
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class NoAnnotationTest {
|
||||
@Test
|
||||
fun testNoAnnotation() {
|
||||
Assertions.assertThrows<IllegalStateException>(IllegalStateException::class.java) {
|
||||
projectFixture().get()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user