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

Add option to filter full stacktrace #261

Open
shwaka opened this issue Mar 12, 2022 · 2 comments
Open

Add option to filter full stacktrace #261

shwaka opened this issue Mar 12, 2022 · 2 comments
Assignees
Labels

Comments

@shwaka
Copy link

shwaka commented Mar 12, 2022

Description

When showFullStackTraces is true, the plugin prints the whole stacktrace.
But I think that most lines of the stacktrace is useless since they come from test framework (e.g. Kotest).
So I request a feature that can filter lines of a stacktrace.

Additional information

Example

(See shwaka/gradle-test-logger-issue for the complete example.)

Consider the following simple code.

// main/kotlin/Foo.kt
class Foo {
    fun method1(): Int {
        return this.method2()
    }

    private fun method2(): Int {
        return this.divideByZero()
    }

    private fun divideByZero(): Int {
        return 1 / 0
    }
}

// test/kotlin/FooTest.kt
class FooTest : StringSpec({
    "failing test" {
        val foo = Foo()
        foo.method1() shouldBe 1
    }
})

This test fails since the method divideByZero() throws an error.
Using the plugin with showFullStackTraces = true, the output looks like as follows:

Screenshot from 2022-03-12 11-18-35

But all lines below the 7th line of the stacktrace have class names starting from io.kotest or kotlinx.coroutines, which are useless for debugging.
So I want to filter the stacktrace as follows:

Screenshot from 2022-03-12 11-17-54

Implementation

I have a fork shwaka/gradle-test-logger-plugin which implements the filtering feature.
Setting filterFullStackTraces = "io\\.kotest.*", the plugin will filter stacktrace as in the 2nd screenshot.

I'm willing to create a pull request if you like it.

@koppor
Copy link

koppor commented Jan 3, 2023

@shwaka Could you create a pull request right ahead, so that other developers browsing this repository see it, too?

@shwaka
Copy link
Author

shwaka commented Jan 4, 2023

Sure!
I will do it in a few days.

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