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 toggle for stack traces from verify #427

Closed
kkurczewski opened this issue Apr 9, 2020 · 13 comments
Closed

Add toggle for stack traces from verify #427

kkurczewski opened this issue Apr 9, 2020 · 13 comments

Comments

@kkurczewski
Copy link
Contributor

In #19 there was added feature to show stack trace when verify expectation failed.

I don't find this stack trace useful most of the time. More often I'm rather interested what exactly failed and long stack trace on bottom forces me to scrolling up for actual root cause.

Can we make some toggle for this feature? I would prefer to manually switching this on.

Naive solution:
verify(printStackTrace = true) { ... }

@oleksiyp
Copy link
Collaborator

Created special settings flag: https://github.com/mockk/mockk/blob/develop/README.md#settings-file

Committed to develop branch

@kkurczewski
Copy link
Contributor Author

Cool to see, thanks :)

@pusolito
Copy link

This doesn't seem to work for me. I've tried flipping the config back and forth with same result: long stack traces when verification fails. I've also confirmed that other settings (i.e. relaxed) work. Flipping it to false makes tests that assumed relaxed mocks fail. What am I missing?

here's my settings file:

resources/io/mock/settings.properties
--------------------------------------

relaxed=true
relaxUnitFun=true
#recordPrivateCalls=false
stackTracesOnVerify=false

@olbpetersson
Copy link

@oleksiyp is there anyway to do this programmatically if you'd like to avoid having a settings-file? Didn't find anything in the code base or the source code when jumping in via intellij

1 similar comment
@olbpetersson
Copy link

@oleksiyp is there anyway to do this programmatically if you'd like to avoid having a settings-file? Didn't find anything in the code base or the source code when jumping in via intellij

@oleksiyp
Copy link
Collaborator

No way currently only. Only settings file

@guilherme-pereira-ifood
Copy link

guilherme-pereira-ifood commented Aug 18, 2020

stackTracesOnVerify=false on settings.properties not working for me too. We're suffering with huge logs when tests fails, is there any workaround for this?

@Raibaz
Copy link
Collaborator

Raibaz commented Mar 11, 2021

Need to check this again.

@kkurczewski
Copy link
Contributor Author

I could take a look on this if someone could provide me instruction how build jar and release it to local repository. I tried just running:

./gradlew build

But it fails on missing dependency:

* What went wrong:
Could not determine the dependencies of task ':mockk-agent-api:dokkaJavadoc'.
> Could not resolve all task dependencies for configuration ':mockk-agent-api:dokkaJavadocPlugin'.
   > Could not find com.soywiz.korlibs.korte:korte-jvm:1.10.3.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/com/soywiz/korlibs/korte/korte-jvm/1.10.3/korte-jvm-1.10.3.pom
       - https://dl.google.com/dl/android/maven2/com/soywiz/korlibs/korte/korte-jvm/1.10.3/korte-jvm-1.10.3.pom
     Required by:
         project :mockk-agent-api > org.jetbrains.dokka:javadoc-plugin:1.4.20
   > Could not find org.jetbrains.kotlinx:kotlinx-html-jvm:0.7.2.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/org/jetbrains/kotlinx/kotlinx-html-jvm/0.7.2/kotlinx-html-jvm-0.7.2.pom
       - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlinx/kotlinx-html-jvm/0.7.2/kotlinx-html-jvm-0.7.2.pom
     Required by:
         project :mockk-agent-api > org.jetbrains.dokka:javadoc-plugin:1.4.20
         project :mockk-agent-api > org.jetbrains.dokka:javadoc-plugin:1.4.20 > org.jetbrains.dokka:dokka-base:1.4.20

So, if someone could tell me how I can create local artifact from code then I can take a look what's going on under hood.

@Raibaz
Copy link
Collaborator

Raibaz commented Oct 15, 2021

To get the build to pass with a freshly-cloned repo I think you can just skip the dokka Javadoc generation by doing

./gradlew build -x dokkaJavadoc

It shouldn't be a big deal not to have dokka generating the docs on your machine :)

@kkurczewski
Copy link
Contributor Author

I have to comment out some stuff and exclude dokka plugin in order to build artifact. Anyway, root cause was that not every path that printed stack trace was covered with flag check, PR above should fix issue.

@piotrb5e3
Copy link

Can this issue be closed? Was it resolved?

@Raibaz
Copy link
Collaborator

Raibaz commented Oct 14, 2022

Yes, thanks.

@Raibaz Raibaz closed this as completed Oct 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants