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

MissingPluginException when trying to run tests #1215

Open
jvaleski opened this issue Mar 29, 2024 · 6 comments
Open

MissingPluginException when trying to run tests #1215

jvaleski opened this issue Mar 29, 2024 · 6 comments
Assignees
Labels
1 backlog bug Something isn't working

Comments

@jvaleski
Copy link

Which API doesn't behave as documented, and how does it misbehave?
setUrl() appears to be causing two MissingPluginExceptions to be raised when I run my test via

flutter test test/file_access_test.dart

Minimal reproduction project
test/file_access_test.dart

import 'package:flutter_test/flutter_test.dart';
import 'package:just_audio/just_audio.dart';

void main() {
  TestWidgetsFlutterBinding.ensureInitialized();
  test("HTTP Access test", () async {
    final player = AudioPlayer();
    await player.setUrl("https://s3.amazonaws.com/404-file.mp3");
  });
}

pubspec.yaml for just_audio and tests

just_audio: ^0.9.36
test: ^1.24.9
integration_test:
  sdk: flutter

To Reproduce (i.e. user steps, not code)
Steps to reproduce the behavior:

  1. create above file in test dir w/ referenced test code
  2. run tests w/ above command

Error messages

00:01 +0 -1: HTTP Access test [E]                                                                                                                                         
  MissingPluginException(No implementation found for method disposeAllPlayers on channel com.ryanheise.just_audio.methods)
  package:flutter/src/services/platform_channel.dart 332:7                    MethodChannel._invokeMethod
  ===== asynchronous gap ===========================
  dart:async                                                                  _CustomZone.registerBinaryCallback
  package:just_audio_platform_interface/method_channel_just_audio.dart 29:10  MethodChannelJustAudio.disposeAllPlayers
  package:just_audio/just_audio.dart 30:22                                    _pluginPlatform
  package:just_audio/just_audio.dart 1370:38                                  AudioPlayer._setPlatformActive.setPlatform
  package:just_audio/just_audio.dart 1481:17                                  AudioPlayer._setPlatformActive
  package:just_audio/just_audio.dart 803:20                                   AudioPlayer.load
  package:just_audio/just_audio.dart 774:24                                   AudioPlayer.setAudioSource
  package:just_audio/just_audio.dart 687:7                                    AudioPlayer.setUrl
  test/file_access_test.dart 8:18                                             main.<fn>
  
  MissingPluginException(No implementation found for method init on channel com.ryanheise.just_audio.methods)
  package:flutter/src/services/platform_channel.dart 332:7  MethodChannel._invokeMethod
  ===== asynchronous gap ===========================
  dart:async                                                _CustomZone.registerBinaryCallback
  package:just_audio/just_audio.dart 1370:13                AudioPlayer._setPlatformActive.setPlatform
  package:just_audio/just_audio.dart 1481:17                AudioPlayer._setPlatformActive
  package:just_audio/just_audio.dart 803:20                 AudioPlayer.load
  package:just_audio/just_audio.dart 774:24                 AudioPlayer.setAudioSource
  package:just_audio/just_audio.dart 687:7                  AudioPlayer.setUrl
  test/file_access_test.dart 8:18                           main.<fn>

Expected behavior
expecting that things run without the exception issue

Desktop (please complete the following information):

dart --version
Dart SDK version: 3.3.3 (stable) (Tue Mar 26 14:21:33 2024 +0000) on "macos_arm64"

Flutter SDK version

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.5, on macOS 14.4.1 23E224 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.3.6)
[✓] IntelliJ IDEA Community Edition (version 2022.3.3)
[✓] VS Code (version 1.87.2)
[✓] Connected device (3 available)
[✓] Network resources
@jvaleski jvaleski added 1 backlog bug Something isn't working labels Mar 29, 2024
@mjjoshi
Copy link

mjjoshi commented Apr 18, 2024

@ryanheise can you please let us know how can we resolve this issue

@PKiman
Copy link

PKiman commented May 15, 2024

Same issue here. Unit test fails.
But plugin is tagged for ANDROID IOS MACOS WEB support.

https://pub.dev/packages/just_audio

MissingPluginException(No implementation found for method disposeAllPlayers on channel com.ryanheise.just_audio.methods)
  package:flutter/src/services/platform_channel.dart 308:7                    MethodChannel._invokeMethod
  ===== asynchronous gap ===========================
  dart:async                                                                  _CustomZone.registerBinaryCallback
  package:just_audio_platform_interface/method_channel_just_audio.dart 29:10  MethodChannelJustAudio.disposeAllPlayers
  package:just_audio/just_audio.dart 30:22                                    _pluginPlatform
  package:just_audio/just_audio.dart 1340:38                                  AudioPlayer._setPlatformActive.setPlatform
  package:just_audio/just_audio.dart 1451:17                                  AudioPlayer._setPlatformActive
  package:just_audio/just_audio.dart 784:20                                   AudioPlayer.load
  package:just_audio/just_audio.dart 755:24                                   AudioPlayer.setAudioSource
  package:just_audio/just_audio.dart 687:7                                    AudioPlayer.setFilePath

@ryanheise
Copy link
Owner

@PKiman , what kind of test are you using? A unit test or an integration test?

@jvaleski please take a look at the unit tests included in this repo under just_audio/test/just_audio_test.dart which are working (although admittedly not very idiomatic, currently).

@PKiman
Copy link

PKiman commented May 15, 2024

I am using unit test in another software project.

@PKiman
Copy link

PKiman commented May 15, 2024

These lines are enough to produce the error on MacOS:

flutter clean && flutter test

minimal_test.dart

import 'package:just_audio/just_audio.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

void main() async {
  TestWidgetsFlutterBinding.ensureInitialized();

  group('test group1', () {
    test('Test 1', () {
      final AudioPlayer player = AudioPlayer();
      final durationObj = await player.setFilePath('path_to_audio.m4a');
      player.dispose();
   });
  });
}

@ryanheise
Copy link
Owner

Have you tried the unit tests in this repository?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 backlog bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants