Mockk: Stack traces are centered instead of aligned left

Created on 12 Jun 2018  路  5Comments  路  Source: mockk/mockk

Expected Behavior

As usual with stacktraces, it's expected that when an error happens, the stacktrace is place all left aligned with no spaces in-between. This is easy to read the error and to quickly find the origin point.

Current Behavior

At the exact moment, the stack traces are being placed in the middle of the console. I'm not sure if this is intentional, but it's not an usual behaviour for stacktraces, so I'm labelling this as a bug.

Code to reproduce:

 class Foo {
        fun bar() = "X"
    }

    @Test
    fun `Mock error`(){
        val mockedFoo: Foo = mockk()

        every { mockedFoo.bar() } returns "Y"

        mockedFoo.bar()

        verify(exactly = 2) { mockedFoo.bar() }

    }

This will generate a stacktrace, as only one call will happen. However, when trying to debug the stacktrace, it's all oddly aligned:
image

The expected formatting can be seen on the bottom, starting at at io.mockk.impl.recording.states.VerifyingState.failIfNotPassed(VerifyingState.kt:64).

I'm not even sure if this method is supposed to have this many amount of lines in the stacktrace, as it's not interesting ofr the user to see Mockk stacktraces, just their code stacktraces, but this is a discussion for another issue.

bug small

Most helpful comment

I've never came across a stack trace - regardless of language or framework - that isn't left-aligned. I'm very used to and quick at reading "normal" stack traces.

"We've always done it like this" isn't a justification and I'm always open for new, good ideas. But I fail to see how doing things differently than everyone else is a good idea in this particular case:

Centered stack trace is a PITA

Even though I don't usually have the Event Log opened, it emphasizes how painful this is. I recommend sticking to the de-facto standard by default and add a config option for people who somehow find centered stack traces helpful.

Even worse, it's mixed:

image

All 5 comments

Centering stack traces is a feature for better readability. Usual stack traces is a mess that I am usually not able to read. Do you have some specific issues with that? i.e. it is not parsable by some tool? IDEA parses locations well, so basically I don't know why this should be changed.

Some coworkers and I were debugging a failing test that was implemented with mock, and we were surprised by a centralized stacktrace.

As we've never seen that before, it was hard to read it without using the horizontal scrolls and resizing the console to fit the whole window.

Believing this wasn't an intentional behaviour, as it's not usual to have centralized stacktraces, I thought of reporting it as a minor bug.

I understand that you may need to get used to it. But when initial time spent learning, I believe centered stack traces have their benefits. I am closing this issue. If more reports from different people appear I'll consider changing it. Thanks.

I've never came across a stack trace - regardless of language or framework - that isn't left-aligned. I'm very used to and quick at reading "normal" stack traces.

"We've always done it like this" isn't a justification and I'm always open for new, good ideas. But I fail to see how doing things differently than everyone else is a good idea in this particular case:

Centered stack trace is a PITA

Even though I don't usually have the Event Log opened, it emphasizes how painful this is. I recommend sticking to the de-facto standard by default and add a config option for people who somehow find centered stack traces helpful.

Even worse, it's mixed:

image

Sent out #543 adding a config settings to determine the alignment of the stack traces.

Was this page helpful?
0 / 5 - 0 ratings