-
Notifications
You must be signed in to change notification settings - Fork 218
Add ability to run solo tests #127
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
Comments
This functionality was very intentionally moved to being handled via command-line flags. Modifying test code to support choosing which tests to run was always a hack; it only existed to work around the inability to consistently parse command-line arguments in tests. It makes it really easy to accidentally check in a change that silently disables a bunch of your tests, and really hard for tooling to select which tests to run. |
This makes sense. However having to create a new test runner in the dart editor with the correct command line flags evertime I want to execute a single test is a bit tedious. Perhaps creating a @test and @testgroup annotation for tests would allow some IDE tooling to select just a single test or group of tests for execution (like what is done in TestNG and JUnit). |
It seems way easier for IDE tooling to pass an argument to the test runner than to modify the test code itself. |
Reopening the issue. I'm fine with allowing isolating tests from the command line, but disallowing isolating tests in the test code is a big big loss in developer productivity. Typing strings on the command line means a lot more typing and also either having to copy the text to paste (which involves many more mouse clicks and keystrokes) or memorizing and carefully entering the string/regex yourself. |
@yjbanov This still isn't a feature we plan to add. I understand why it's somewhat easier under some circumstances, but it's also very error-prone and largely redundant with existing functionality. You're welcome to write a wrapper (or eventually a plug-in) that supports this, but there's not going to be direct support.
You can still do this via something like
These are legitimately useful things, but they're not the extent of groups' utility. Groups are used for defining configuration or |
I should also mention that you'll be able to roll your own solo testing to some degree once #16 is implemented. If you write something like |
I agree that's a cleaner API, but it still does not provide sufficient ergonomics for fast-paced test-driven workflows such as the one used by Angular and the users of Angular. We prefer to run our tests continuously, so you do not even have to switch away from your code editor. You pick a collection of tests you want to run (via isolating them in the code, where your focus is), save file and the test runner (sensing file system changes) reruns everything automatically. This allows very fast code/test iterations (on the order of seconds per iteration). Having to go to the command-line and to enter flags would slow down the process significantly, as would having to enter I suppose we should be able to wrap BTW, the problem of the risk of submitting isolated tests can be easily solved by the command-line flag to the test runner |
A continuous test runner like the one you're describing doesn't exist yet; once it does it will likely be in a different package that builds on the For now, though, this package only supports batch-mode running. In batch mode a combination of |
Re-opening to give this yet another nudge. I understand the principle behind the choice not to implement this but in practice it's a CONSTANT drag. I'm w/ @yjbanov on the plea for better ergonomics out of the box. |
This is still not something we plan to support directly (although again, it will be possible to do something very similar with #16). This isn't a feature that's supported in any other solely-batch-mode test runner that I know of—every other language ecosystem (other than JS which uses a live test runner) is very content with passing the name of the test or using tagging. It's also not something that we can support in a way that matches user expectations. The test runner runs multiple files, and users expect focused tests to work across files—for example, this is how it works in Karma. But a batch-mode test runner can't load all of the test files at once; |
This is how it might work. While // instead of importing 'package:test' you would
import 'package:test_wrapper/test.dart';
main() {
group('a', () {
solo_test('should b', () {});
});
solo_group('c', () {
test('should d', () {});
});
} Just like ol' times. Then locally you'd run I think |
This is still not something we plan to support directly. I disagree that tags are terrible ergonomics; of course, that's a judgment call, but as you point out it's very possible for you to create a wrapper that provides the ergonomics you prefer. Including a tagged alias for |
@nex3 would you care to give an update for reasons why not? I think the issue of accidentally excluding tests was addressed, the feature is both highly requested and also completely opt-in. I can buy the "we cannot" argument from #127 (comment), but let's discuss feasibility separately from merit. First, I'd like to hear a good reason for why this is not a good feature. As for ergonomics, let's allow people who actually use this feature to make the call. I'm guessing as ardent opponent of it, you are not one of them. |
On Fri, Oct 9, 2015 at 2:47 AM, Yegor [email protected] wrote:
/LLasse R.H. Nielsen - [email protected]
|
FWIW the lack of |
@yjbanov Please stop re-opening this issue; if I change my mind, I'll re-open it myself, but until then it's not helping anything.
Adding new features fundamentally comes at a cost, at the very least to complexity and surface area. A new feature isn't inherently good; it must provide enough value to justify its cost. The feature you're proposing doesn't provide much value at all—moving a parameter from the end of a function call to the name—and the cost is relatively high. It would be inconsistent on several different axes:
I used |
Therein lies the rub (my emphasis). I categorically don't run tests from the command-line when I can from within my editor. The command-line is particularly unappealing when I'm running tests in the debugger (basically all the time when I'm running solo tests). |
[EDIT: added Phil's IDE use-case; grammar] Ok with discussing it while closed. Let's see if I can summarize the desired qualities of the solution:
Here's are some additional desired qualities that prompted the creation of this issue: a. it has to be ergonomic Status quo
#16#16 would satisfy c, as a developer no longer needs to change command-line args between runs. It's slightly better ergonomically, but far from ideal. Here's are some problems with ergonomics:
#16 also loses b. I'd like to find one method that satisfies a, b, d and e simultaneously, without losing any of the others. Solution#127 (comment) shows one way we can solve d and e. However, it requires a separate package, which means it would not be standard and teams that need to work with many 3rd-party packages need to learn that particular project's conventions. For example, the Angular team needs to fix a myriad of other projects when releasing breaking changes, and it's already pretty hard due to different projects configurations. And we very routinely run people's tests and isolate them for finer grained debugging. This would make things worse. Ultimate solution: provide |
Other than a small amount of extra typing, this is subjective. I rarely find myself typing-speed-bound when I'm debugging, so I find consistency a much more important component of ergonomics.
I agree with this one, but I'd broaden it to "consistent". Your consistency of experience across multiple repositories needs to be balanced against the consistency of peoples' experiences configuring their tests and across test frameworks. Also, Angular already uses
As I've mentioned above, the I would expect most IDEs to gracefully support this use-case, in the simplest case by allowing arguments to be passed manually to the test runner or by being more advanced and pulling the name of the test automatically. The vast majority of languages' test runners work like
I consider this something nice to have where possible, but not a requirement. We won't ever be able to make it entirely familiar—the method names, for example, are already set in stone. And explicitly requiring these users to tag their tests will produce less friction anyway, because they won't have the same expectations of how it will work that we won't be able to satisfy.
Searching for "solo" will do this in either case. I just don't find the benefits that come from an additional test method compelling relative to the costs. It's a very small additional amount of work, and if that's still too much Guinness already exists as a place to add |
Please consider this very real use case that makes this a really bad DevExp decision, imho.
My options right now:
I would strongly prefer something like |
@filiph you will have |
@filiph The bugs you're seeing should be fixed at the source, not worked around by adding extra features. In particular:
Luckily, there are ways of locating your package's assets, at least if you aren't using transformers, which it sounds like you aren't. This is also going to get a lot simpler soon (hopefully in 1.14). The
Running a test file directly with the command-line VM is a shortcut. If you're being forced into it, your code is probably making too many assumptions (in this case about It's also worth noting that even if we added a |
What about adding "xtest()" method a-la Jest to quickly disable tests. |
Note that we support the It is marked as deprecated to help prevent users from checking in solo tests which would negatively impact their test coverage. |
something like test(solo:true) even better a Test annotation that can be selected from the dart editor to select that only a single test should run
The text was updated successfully, but these errors were encountered: