felangel / mocktail

A mock library for Dart inspired by mockito
https://pub.dev/packages/mocktail
MIT License
588 stars 80 forks source link

Not compatible with freezed 2.4.2 #207

Closed rxseb closed 9 months ago

rxseb commented 10 months ago

Describe the bug Mocktail is not compatible with latest freezed version (2.4.2).

To Reproduce

  1. flutter create sample_app
  2. Install freezed
  3. flutter pub add --dev mocktail
  4. See error
    
    The current Dart SDK version is 3.0.2.

Because test >=1.16.0-nullsafety.19 <1.16.6 depends on test_api 0.2.19 and test >=1.16.6 <1.17.10 depends on analyzer ^1.0.0, test >=1.16.0-nullsafety.19 <1.17.10 requires test_api 0.2.19 or analyzer ^1.0.0. And because test >=1.17.10 <1.20.0 depends on analyzer >=1.0.0 <3.0.0, test >=1.16.0-nullsafety.19 <1.20.0 requires test_api 0.2.19 or analyzer >=1.0.0 <3.0.0. And because test >=1.20.0 <1.21.2 depends on test_api 0.4.9 and test >=1.21.0 <1.21.6 depends on analyzer >=2.0.0 <5.0.0, test >=1.16.0-nullsafety.19 <1.21.6 requires test_api 0.2.19 or 0.4.9 or analyzer >=1.0.0 <5.0.0. And because test >=1.21.6 <1.24.4 depends on analyzer >=2.0.0 <6.0.0 and test >=1.24.4 depends on test_api 0.6.1, test >=1.16.0-nullsafety.19 requires test_api 0.2.19 or 0.4.9 or 0.6.1 or analyzer >=1.0.0 <6.0.0. And because freezed >=2.4.2 depends on analyzer ^6.0.0 and matcher >=0.12.15 <0.12.16 depends on test_api ^0.5.0, one of freezed >=2.4.2 or test >=1.16.0-nullsafety.19 or matcher >=0.12.15 <0.12.16 must be false. And because every version of flutter_test from sdk depends on matcher 0.12.15 and mocktail >=0.1.3 depends on test ^1.16.0, one of freezed >=2.4.2 or flutter_test from sdk or mocktail >=0.1.3 must be false. And because mocktail <0.1.3 requires SDK version >=2.12.0-0 <2.17.0 and sample_app depends on flutter_test from sdk, freezed >=2.4.2 is incompatible with mocktail. So, because sample_app depends on both freezed ^2.4.2 and mocktail any, version solving failed.


**Logs**

<details><summary>flutter doctor -v</summary>
[!] Flutter (Channel unknown, 3.10.2, on Microsoft Windows [Version 10.0.22621.1992], locale en-CH)
    ! Flutter version 3.10.2 on channel unknown at D:\install\flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
    ! Unknown upstream repository.
      Reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
    • Framework revision 9cd3d0d9ff (3 months ago), 2023-05-23 20:57:28 -0700
    • Engine revision 90fa3ae28f
    • Dart version 3.0.2
    • DevTools version 2.23.1
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Windows Version (Installed version of Windows is version 10 or higher)

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at D:\Users\srou\AppData\Local\Android\sdk
    • Platform android-33-ext5, build-tools 33.0.2
    • Java binary at: C:\Program Files\Eclipse Adoptium\jdk-17.0.6.10-hotspot\bin\java
    • Java version OpenJDK Runtime Environment Temurin-17.0.6+10 (build 17.0.6+10)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[✓] Visual Studio - develop for Windows (Visual Studio Build Tools 2022 17.6.2)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools
    • Visual Studio Build Tools 2022 version 17.6.33723.286
    • Windows 10 SDK version 10.0.22621.0

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).

[✓] IntelliJ IDEA Ultimate Edition (version 2023.2)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2023.1
    • Flutter plugin version 75.1.4
    • Dart plugin version 232.8660.129

[✓] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22621.1992]
    • Chrome (web)      • chrome  • web-javascript • unknown
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 115.0.1901.203

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 2 categories.
</details>

**pubspec.yaml**

name: sample_app description: A new Flutter project. publish_to: 'none' version: 1.0.0+1

environment: sdk: '>=3.0.2 <4.0.0'

dependencies: flutter: sdk: flutter cupertino_icons: ^1.0.2 freezed_annotation: ^2.4.1

dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^2.0.0 build_runner: ^2.4.6 freezed: ^2.4.2

flutter: uses-material-design: true

omensight commented 9 months ago

Yep, I think it is because the test package, mocktail is currently using a version of the test package 2 years old.

felangel commented 9 months ago

Yep, I think it is because the test package, mocktail is currently using a version of the test package 2 years old.

The test version constraint that mocktail has supports the latest version of package:test so that shouldn’t be an issue.

rxseb commented 9 months ago

I think @omensight is right. According to the error message the conflict comes from incompatible resolution for analyzer version, which needs to be >=6.0.0 for freezed 2.4.2, but <6.0.0 for test ^1.16.

test package increased its analyzer version constraint since 1.24.4. So I guess increasing test version constraint to ^1.24.4 should make mocktail compatible with packages requiring analyzer >=6.0.0.

felangel commented 9 months ago

This is due to an incompatibility between package:test (from mocktail), package:analyzer (from freezed), and flutter_test (from the flutter sdk). I took a closer look and I think mocktail can safely avoid depending on package:test with minimal impact to end users which should resolve this sort of issue moving forward (as this isn't the first time this has happened).

felangel commented 9 months ago

This should be resolved in mocktail v1.0.1 apologies for the inconvenience! 👍