Using testify for profiling while having SetupSuite
Answered
Hello,
I'm trying to run my tests with profiling (while clicking on run on struct in IDE), I'm using testify with SetupSuite to load config and extra files.
However when I'm running it via test configuration it works perfectly
Please sign in to leave a comment.
Hi,
Could you please provide a bit more details and exact steps to reproduce the issue with a code example? What errors appear on the screen? Are you running the configuration by clicking on the gutter icon near a test name or package/directory?
The one that runs for me is there are all builds configurations are made, the one that fails is in near dir on left side
This is a code example that I run https://pastebin.com/Z33yRtay
This is error I receive https://pastebin.com/btUF7Qsg
It seems on line 63 at suite.go you refer a field from a nil-pointer. Your example doesn't fully relate to stacktraces that come from Go. It's a runtime error.
I guess it's a line with dictionaries.GDictionaries.LoadDictionaries() statement. e.g.
Return the same error. Please, check the source code and make sure that Dictionaries is created. Like in my example I need to change the main function a bit:
or you can just skip the pointer:
I hope it helps.
But why it works fine while running from configuration?
I've tried to change to edit it like so, is it like you mentioned?
https://pastebin.com/vDZs2ck4
But unfortunately it still returns the same error
I even tried this now, still the same error
Ok seems like in this way to start it config doesn't read properly
That causes error in reading dicts
Seems like I've managed to fix it, reason was in config as I mentioned
So the difference is in how IDE is running both configs
If I run it from top template it will execute in go run subdir
But if I run it via play next to project dir it will execute it in testing subdir
That's true, if you're executing tests by clicking on a directory, then all tests will be executed recursively (similar to go test ./...).
If you're executing a test by clicking on the run gutter icon near the package name, then only tests inside that package will be executed.
Maybe this needed to be added into documentation, since for running test properly I'm reading config file for it without using absolute path
So maybe this needed to be stated on docs page, because it was really unexpected behaviour.
Thanks for pointing that out, we'll think about how to improve docs and make it more clear in the case with run tests. By the way, you can check out Create a run/debug configuration article.