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
compile-test-snippets
is confusing for new contributors
#4874
Comments
Follow up here: This is yet another thing than can be easily automated with Danger (see more on this here #4696 (reply in thread)). Essentially, once the CI results are complete, this can be one of the message reports on the PR by danger. Something along the line of "hey the |
A near-ideal solution might be to have |
That's not really easy as, I suppose, you're running a single test inside the IDE. That's at least what I do. So you'll anyway have to instruct the user on how to configure the run config for that specific test |
Yep, that's the same situation I'd like to catch; what I'd ideally like to see is a way to automatically capture the running test context and adjust the snippet compilation accordingly. It's not out of the question, for example:
I believe will be able to capture only test classes/methods run from the IDE (or from the CLI with some arcane configuration I can never remember). But of course we don't want to have this logic in each test; whether there's some way to access this data from |
That is doable I think, yet I think that modifying the env between running 1 or N tests is not the best practice. It might create frustrations during local development and generally confuse new contributors. |
I understand the idea and it have sense but I agree with Nico here. It could create even more confusion. Why does a test work if I run Something similar could be asked about local/CI but I think that we could clarify that easier. |
Yeah, I agree it can be confusing... on the other hand, so is the current practice 🤷 Just brainstorming some ideas, here are a couple more:
|
I'd like to add that one more thing that got me a bit confused while reading detekt source code is that project property Relevant lines are in the same file: one, two. Setting the first one will only work in detekt repository and won't work in rule authors' repostories, but setting the system property with the latter name should work in other repositories too (it's actually being read by Maybe uniting them somehow could help here. |
Fixed here #5630 That's however out of the scope of this issue, as the underlying problem is that users don't understand that we have an 'extra' step where we effectively compile the test snippets source code, and that's running only under certain conditions. |
### A bit of context:
Our unit tests contain a lot of code snippets. Because, in general, we don't compile that code, it's easy to write code that doesn't compile. That makes that our tests doesn't test what we want. To avoid this problem we compile all the snippets to ensure that they are valid.
Problem: This extra step consumes a lot of execution time making our tests even more slow.
Solution: Because this check is testing the test code (and it's not testing production code) it's ok if we don't run it every time. So we just check it on CI.
Current state
But that solution has a problem! The new contributors are bitten by this on CI and they don't know what's going on (an example is #4872 but we had a lot of these in the past).
One possible solution
We could configure a "bot" to write a comment explaining this when the workflow
compile-test-snippets
fails. This will give fast feedback to the contributor about what's going on, why we have this "strange" behaviour and how s/he can reproduce it locally.This is an issue and it's not a PR because the actions that I found to add that comment doesn't work when the PRs come from fork repository. And that's exactly the case when we want to add that comment.
The text was updated successfully, but these errors were encountered: