Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Issue 709903004: Enhance the Dart unittest library to support multiple invocations in the same application run. (Closed)

Created:
6 years, 1 month ago by wibling
Modified:
6 years, 1 month ago
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Enhance the Dart unittest library to support multiple invocations in the same application run. I am creating e2e tests for dart on App Engine and want to avoid redeploying the app each time I need to run a specific set of tests. Instead I have enhanced the unittest library with a method which creates a new "global" test environment which can be used for this specific run of tests. Before I had to redeploy the app each time (takes ~2-4mins) to get a fresh test environment. BUG= R=kevmoo@google.com, kustermann@google.com Committed: https://code.google.com/p/dart/source/detail?r=41741

Patch Set 1 #

Patch Set 2 : #

Total comments: 10

Patch Set 3 : review feedback #

Total comments: 2

Patch Set 4 : make TestEnvironment private #

Total comments: 4

Patch Set 5 : review feedback #

Total comments: 12

Patch Set 6 : more review feedback #

Total comments: 53

Patch Set 7 : nweiz feedback #

Patch Set 8 : #

Total comments: 7
Unified diffs Side-by-side diffs Delta from patch set Stats (+184 lines, -70 lines) Patch
M pkg/unittest/CHANGELOG.md View 1 2 3 4 5 6 7 1 chunk +1 line, -0 lines 0 comments Download
M pkg/unittest/lib/src/group_context.dart View 1 chunk +1 line, -1 line 0 comments Download
M pkg/unittest/lib/src/test_case.dart View 1 chunk +3 lines, -3 lines 0 comments Download
A pkg/unittest/lib/src/test_environment.dart View 1 2 3 4 5 6 7 1 chunk +54 lines, -0 lines 5 comments Download
M pkg/unittest/lib/unittest.dart View 1 2 3 4 5 6 7 16 chunks +76 lines, -65 lines 2 comments Download
M pkg/unittest/pubspec.yaml View 1 2 3 4 5 6 7 1 chunk +1 line, -1 line 0 comments Download
A pkg/unittest/test/with_test_environment_test.dart View 1 2 3 4 5 6 1 chunk +48 lines, -0 lines 0 comments Download

Messages

Total messages: 26 (1 generated)
wibling
6 years, 1 month ago (2014-11-10 09:27:54 UTC) #2
kustermann
https://codereview.chromium.org/709903004/diff/20001/pkg/unittest/lib/unittest.dart File pkg/unittest/lib/unittest.dart (right): https://codereview.chromium.org/709903004/diff/20001/pkg/unittest/lib/unittest.dart#newcode158 pkg/unittest/lib/unittest.dart:158: TestEnvironment _defaultEnvironment = new TestEnvironment(); Make this final. https://codereview.chromium.org/709903004/diff/20001/pkg/unittest/lib/unittest.dart#newcode217 ...
6 years, 1 month ago (2014-11-10 11:37:38 UTC) #3
kustermann
You should also add some kind of test to pkg/unittest/test for this.
6 years, 1 month ago (2014-11-10 11:38:06 UTC) #4
kevmoo
On 2014/11/10 11:38:06, kustermann wrote: > You should also add some kind of test to ...
6 years, 1 month ago (2014-11-10 17:36:36 UTC) #5
wibling
On 2014/11/10 11:38:06, kustermann wrote: > You should also add some kind of test to ...
6 years, 1 month ago (2014-11-11 12:18:26 UTC) #6
wibling
Thanks for the reviews! I have incorporated the feedback and added a test. https://codereview.chromium.org/709903004/diff/20001/pkg/unittest/lib/unittest.dart File ...
6 years, 1 month ago (2014-11-11 12:18:55 UTC) #7
kevmoo
LGTM with comments https://codereview.chromium.org/709903004/diff/40001/pkg/unittest/lib/src/test_environment.dart File pkg/unittest/lib/src/test_environment.dart (right): https://codereview.chromium.org/709903004/diff/40001/pkg/unittest/lib/src/test_environment.dart#newcode11 pkg/unittest/lib/src/test_environment.dart:11: class TestEnvironment { Does this class ...
6 years, 1 month ago (2014-11-11 15:09:16 UTC) #8
wibling
New diff with private TestEnvironment. https://codereview.chromium.org/709903004/diff/40001/pkg/unittest/lib/src/test_environment.dart File pkg/unittest/lib/src/test_environment.dart (right): https://codereview.chromium.org/709903004/diff/40001/pkg/unittest/lib/src/test_environment.dart#newcode11 pkg/unittest/lib/src/test_environment.dart:11: class TestEnvironment { On ...
6 years, 1 month ago (2014-11-11 15:16:35 UTC) #9
kevmoo
On 2014/11/11 15:16:35, wibling wrote: > New diff with private TestEnvironment. > > https://codereview.chromium.org/709903004/diff/40001/pkg/unittest/lib/src/test_environment.dart > ...
6 years, 1 month ago (2014-11-11 15:42:17 UTC) #10
wibling
On 2014/11/11 15:42:17, kevmoo wrote: > On 2014/11/11 15:16:35, wibling wrote: > > New diff ...
6 years, 1 month ago (2014-11-11 16:16:39 UTC) #11
wibling
On 2014/11/11 16:16:39, wibling wrote: > On 2014/11/11 15:42:17, kevmoo wrote: > > On 2014/11/11 ...
6 years, 1 month ago (2014-11-11 16:46:24 UTC) #12
kustermann
LGTM -- great change to fix unittest, getting rid of the global state :) Please ...
6 years, 1 month ago (2014-11-11 16:46:25 UTC) #13
wibling
Thanks for the review! Updated as suggested. https://codereview.chromium.org/709903004/diff/60001/pkg/unittest/test/with_test_environment_test.dart File pkg/unittest/test/with_test_environment_test.dart (right): https://codereview.chromium.org/709903004/diff/60001/pkg/unittest/test/with_test_environment_test.dart#newcode16 pkg/unittest/test/with_test_environment_test.dart:16: return config.done; ...
6 years, 1 month ago (2014-11-11 16:57:54 UTC) #14
kevmoo
https://codereview.chromium.org/709903004/diff/80001/pkg/unittest/CHANGELOG.md File pkg/unittest/CHANGELOG.md (right): https://codereview.chromium.org/709903004/diff/80001/pkg/unittest/CHANGELOG.md#newcode1 pkg/unittest/CHANGELOG.md:1: ##0.11.0+7 Please make this 0.11.1 – we are adding ...
6 years, 1 month ago (2014-11-11 21:27:53 UTC) #15
wibling
Thanks for the review! I have updated the diff accordingly. @nweiz, do you have any ...
6 years, 1 month ago (2014-11-12 10:33:46 UTC) #16
nweiz
There are some style changes, but this is your first CL so you don't need ...
6 years, 1 month ago (2014-11-12 20:37:12 UTC) #17
kustermann
On 2014/11/12 20:37:12, nweiz wrote: > There are some style changes, but this is your ...
6 years, 1 month ago (2014-11-12 20:57:59 UTC) #18
nweiz
On 2014/11/12 20:57:59, kustermann wrote: > On 2014/11/12 20:37:12, nweiz wrote: > > There are ...
6 years, 1 month ago (2014-11-12 21:07:10 UTC) #19
wibling
On 2014/11/12 21:07:10, nweiz wrote: > On 2014/11/12 20:57:59, kustermann wrote: > > On 2014/11/12 ...
6 years, 1 month ago (2014-11-13 08:24:38 UTC) #20
nweiz
Nitpicks incoming... https://codereview.chromium.org/709903004/diff/100001/pkg/unittest/lib/src/test_environment.dart File pkg/unittest/lib/src/test_environment.dart (right): https://codereview.chromium.org/709903004/diff/100001/pkg/unittest/lib/src/test_environment.dart#newcode7 pkg/unittest/lib/src/test_environment.dart:7: /// Class for encapsulating test environment state. ...
6 years, 1 month ago (2014-11-13 19:34:28 UTC) #21
wibling
Thanks for the detailed review. It is useful to know the general guidelines we have! ...
6 years, 1 month ago (2014-11-14 10:09:49 UTC) #22
wibling
Committed patchset #8 (id:140001) manually as 41741 (presubmit successful).
6 years, 1 month ago (2014-11-14 14:55:01 UTC) #23
nweiz
https://codereview.chromium.org/709903004/diff/100001/pkg/unittest/lib/unittest.dart File pkg/unittest/lib/unittest.dart (right): https://codereview.chromium.org/709903004/diff/100001/pkg/unittest/lib/unittest.dart#newcode156 pkg/unittest/lib/unittest.dart:156: const Symbol _TEST_ENVIRONMENT = #test_environment; On 2014/11/14 10:09:49, wibling ...
6 years, 1 month ago (2014-11-17 23:02:55 UTC) #24
wibling
Thanks for the additional feedback. I have replied inline below and send out a new ...
6 years, 1 month ago (2014-11-18 10:16:49 UTC) #25
nweiz
6 years, 1 month ago (2014-11-19 21:40:39 UTC) #26
Message was sent while issue was closed.
https://codereview.chromium.org/709903004/diff/100001/pkg/unittest/test/with_...
File pkg/unittest/test/with_test_environment_test.dart (right):

https://codereview.chromium.org/709903004/diff/100001/pkg/unittest/test/with_...
pkg/unittest/test/with_test_environment_test.dart:24: void main() {
On 2014/11/18 10:16:49, wibling wrote:
> On 2014/11/17 23:02:54, nweiz wrote:
> > On 2014/11/14 10:09:49, wibling wrote:
> > > On 2014/11/13 19:34:28, nweiz wrote:
> > > > Why doesn't this use metatest to isolate its test cases?
> > > 
> > > I am not sure what the benefit of metatests would be in this case?
> > 
> > metatest allows you to create isolated test run with the normal unittest
> > infrasturcture when testing unittest code. Having a file that just throws an
> > error when it fails rather than printing useful information isn't friendly
to
> > future people working on the code.
> > 
> > > As I mentioned in my reply to Kevin please let me know how this should be
> > tested
> > > using meta tests and I will be happy to change it.
> > 
> > You can look at other unittest test files as examples. Basically, within
each
> > [expectTestResults] you put code that would otherwise be run at the top
level
> of
> > the test and that code is run in isolation.
> 
> I did look at the other tests and also at the metatest code. The problem as I
> see it is that the metatest code is tailored to determine if the tests being
run
> are finishing with the expected results whereas this change is not about the
> results of the specific tests, but whether the setup of the unittest library
> succeeds or not.
> Given that I am not validating the test results I don't understand the value
of
> running this in a metatest?

Oh, I see, that's a good point. It's probably possible to add functionality to
metatest that would support this, but that's not necessary to do now.

https://codereview.chromium.org/709903004/diff/140001/pkg/unittest/lib/src/te...
File pkg/unittest/lib/src/test_environment.dart (right):

https://codereview.chromium.org/709903004/diff/140001/pkg/unittest/lib/src/te...
pkg/unittest/lib/src/test_environment.dart:45: final List<TestCase> testCases =
new List<TestCase>();
On 2014/11/18 10:16:49, wibling wrote:
> On 2014/11/17 23:02:55, nweiz wrote:
> > There's no need to type annotate this, since the type is clear from the
> > initializing expression.
> 
> I am getting mixed feedback here. As far as I have heard and also my personal
> preference we should type annotate fields that are public. Even in a private
> class.

The code in the repo isn't entirely consistent, but across most of the
widely-used Dart-team-authored packages the convention is to include types on
*most* instance variables but to omit them when there's an initializer that
makes the type clear. Basically, the minimum amount of verbosity should be used
that still makes the type clear from the declaration.

Powered by Google App Engine
This is Rietveld 408576698