Files
openide/python/testSrc/com/jetbrains/LoggingRule.kt
Roman Shevchenko 1e5ed93fac [test framework] convenient method for enabling debug logging in tests
GitOrigin-RevId: 51cde493fcb9744feaa77d70d9ddc2b0cd1d2b6d
2022-10-21 08:36:39 +00:00

20 lines
766 B
Kotlin

// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.jetbrains
import com.intellij.openapi.Disposable
import com.intellij.testFramework.TestLoggerFactory
import org.junit.rules.TestRule
/**
* JUnit rule that captures debug logs for certain classes and reports then if test failed
* To start it run [startLogging]
*/
class LoggingRule : TestRule by TestLoggerFactory.createTestWatcher() {
/**
* @param disposable logging will be stopped when [disposable] is disposed
* @param classes classes to enable debug for
*/
fun startLogging(disposable: Disposable, classes: Collection<Class<*>>) =
TestLoggerFactory.enableDebugLogging(disposable, *classes.toTypedArray())
}