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

flutter tests don't compile anymore since the last update #24384

Closed
Irrlick opened this issue Nov 15, 2018 · 5 comments

Comments

Projects
None yet
3 participants
@Irrlick
Copy link

commented Nov 15, 2018

Since today's flutter upgrade, the unit tests in the test folder don't compile anymore, while yesterday evening they still worked flawlessly :(

Compiler message:
Error: Could not resolve the package 'test' in 'package:test/test.dart'.
color_test.dart:4:8: Error: Not found: 'package:test/test.dart'
import "package:test/test.dart";

Here is the dependency in my pubspec.yaml :

dev_dependencies:
  flutter_test:
    sdk: flutter

It worked fine yesterday, so where is the problem ?

And I've also tried reinstalling flutter manually, deleting completely my ~/flutter folder and replacing it with the content of flutter_linux_v0.11.3-beta.tar.xz downloaded from https://flutter.io/setup-linux/ but the test compilation problem remains.

I can still develop my app but I can't run my tests anymore, so that's quite annoying.

What can I do to solve this problem ?

@Irrlick

This comment has been minimized.

Copy link
Author

commented Nov 15, 2018

Just found a workaround :)

Replacing import "package:test/test.dart"; by import 'package:flutter_test/flutter_test.dart'; in all my tests fixed the problem...

I guess this sudden compilation problem has to do with the #23755 change described on https://github.com/flutter/flutter/wiki/Changelog, right ?

May I kindly suggest that each time you release an upgrade which will break the builds, you also suggest a workaround on this web page ?

@Irrlick

This comment has been minimized.

Copy link
Author

commented Nov 15, 2018

I also suggest you fix this web page, as the first example is now obsolete :

https://flutter.io/docs/testing

Example:

Add this file to test/unit_test.dart:

import 'package:test/test.dart';

void main() {
  test('my first unit test', () {
    var answer = 42;
    expect(answer, 42);
  });
}
@jonahwilliams

This comment has been minimized.

Copy link
Contributor

commented Nov 15, 2018

We announced this change via flutter-dev and the changelog:

https://groups.google.com/forum/#!topic/flutter-dev/EppJpBk9eqQ
https://github.com/flutter/flutter/wiki/Changelog
https://stackoverflow.com/questions/53208676/error-target-of-uri-doesnt-exist-packagetest-test-dart/53213000#53213000

All you need to do to keep your tests working as before is add a dependency on package:test. In general, if you are using a package it should be in your pubspec.

dev_dependencies:
  test: ^1.5.1
@Irrlick

This comment has been minimized.

Copy link
Author

commented Nov 16, 2018

Thanks for the quick answer :D

Maybe the problem here was that the google team supposes that every Flutter developer out there is reading every bit of information that is published in the google groups, on stack overflow, etc.

That's not the way it is for most of us...

We all have lot of work to do, and generally not the time we asked to do it, and we search for a solution in the google groups and on stack overflow only when we need to, because otherwise we use our development time to implement what we are paid for.

And that's the first reason we decided to switch to flutter by the way : it significantly increases our productivity, allowing to develop better cross-platform applications, faster.

And yes, we know it's not a stable 1.0 library, so we expect some breaking changes from time to time, even if like everybody I don't like to have my code stop compiling right after an upgrade.

Believe me, I appreciate A LOT that the Google management has decided to allow us to use your in-house technology for our own needs. That's very generous from you !

But may I still suggest that when such breaking change happen, you not only mention it on "https://github.com/flutter/flutter/wiki/Changelog", but also clearly suggest a solution or even just a workaround, on that same page, so we don't have to hunt for a possible solution in the mailing lists, on stack overflow, etc... :)

@jonahwilliams

This comment has been minimized.

Copy link
Contributor

commented Nov 16, 2018

I'm sorry this caused a disruption for you, we'll make sure required changes are more prominently mentioned in the changelog. I went ahead and edited the entry to clarify the breaking change.

@Irrlick Irrlick closed this Nov 16, 2018

murielsilveira added a commit to murielsilveira/titan that referenced this issue Mar 7, 2019

chore: specify test package
as described in this issue: flutter/flutter#24384
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.