Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Add Basic Junit Tests to some plugins #4108

Merged
merged 7 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ android {
dependencies {
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.guava:guava:20.0'
testImplementation 'junit:junit:4.12'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package io.flutter.plugins.googlesignin;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class GoogleSignInTest {
@Test
public void aTest() {
assertEquals(2, 2);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there something from the plugin implementation that we could test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could, but I think this would require me to change the code of each plugin to add a meaningful test. The Java code in most of these plugins weren't designed to be tested and adding a test would require making a method/field public and mocking stuff. I'll add some arbitrary tests

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stuartmorgan any thoughts?

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g Jun 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The primary goal is to have the structure in place so that we can point PR authors to a file to add tests to, rather than saying "you need to add a test file in the right place, then update the build, etc."

A meaningful test is obviously better than not since it provides more of an example to follow, but I'm fine with just having a placeholder in the interests of getting the basic test harness infrastructure in place everywhere. If we do placeholders we should:

  • Clearly comment that it's a placeholder until some real tests are in place (I know it should be obvious, but a first-time contributor could be confused).
  • Ideally have the placeholder do something with the plugin (e.g., in the corresponding iOS changes Jenn had the placeholder test just instantiate the plugin; could we do something similar?). That guarantees that we don't have, say, linking or import issues that someone trying to use it for the first time would immediately hit.

}
}
1 change: 1 addition & 0 deletions packages/local_auth/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies {
api "androidx.core:core:1.3.2"
api "androidx.biometric:biometric:1.1.0"
api "androidx.fragment:fragment:1.3.2"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package io.flutter.plugins.localauth;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class LocalAuthTest {
@Test
public void aTest() {
assertEquals(2, 2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ android {
lintOptions {
disable 'InvalidPackage'
}
dependencies {
testImplementation 'junit:junit:4.12'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package io.flutter.plugins.sharedpreferences;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class SharedPreferencesTest {
@Test
public void aTest() {
assertEquals(2, 2);
}
}
1 change: 1 addition & 0 deletions packages/video_player/video_player/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ android {
implementation 'com.google.android.exoplayer:exoplayer-hls:2.12.1'
implementation 'com.google.android.exoplayer:exoplayer-dash:2.12.1'
implementation 'com.google.android.exoplayer:exoplayer-smoothstreaming:2.12.1'
testImplementation 'junit:junit:4.12'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package io.flutter.plugins.videoplayer;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class VideoPlayerTest {
@Test
public void aTest() {
assertEquals(2, 2);
}
}
1 change: 1 addition & 0 deletions packages/webview_flutter/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ android {
dependencies {
implementation 'androidx.annotation:annotation:1.0.0'
implementation 'androidx.webkit:webkit:1.0.0'
testImplementation 'junit:junit:4.12'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package io.flutter.plugins.webviewflutter;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class WebViewTest {
@Test
public void aTest() {
assertEquals(2, 2);
}
}