[Android] Proper unit testing for Android

Geoffrey Métais git at videolan.org
Mon Jun 1 16:09:07 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jun  1 16:08:38 2015 +0200| [33830308300ee9632d82c8b412975b9373bd2a96] | committer: Geoffrey Métais

Proper unit testing for Android

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=33830308300ee9632d82c8b412975b9373bd2a96
---

 vlc-android/build.gradle                           |    4 +++
 .../org/videolan/vlc/util/StringsTest.java}        |   37 ++++----------------
 2 files changed, 10 insertions(+), 31 deletions(-)

diff --git a/vlc-android/build.gradle b/vlc-android/build.gradle
index 5bd5067..10f1644 100644
--- a/vlc-android/build.gradle
+++ b/vlc-android/build.gradle
@@ -165,6 +165,9 @@ android {
         res.srcDirs = ['res']
         assets.srcDirs = ['assets']
     }
+    sourceSets.test {
+        java.srcDirs = ['test']
+    }
     sourceSets.tv {
         manifest.srcFile 'tv/AndroidManifest.xml'
         java.srcDirs = ['tv/src']
@@ -182,6 +185,7 @@ dependencies {
     compile 'com.android.support:cardview-v7:22.1.1'
     compile 'com.android.support:recyclerview-v7:22.1.1'
     tvCompile 'com.android.support:leanback-v17:22.1.1'
+    testCompile 'junit:junit:4.12'
 }
 
 def buildTime() {
diff --git a/vlc-android/src/org/videolan/vlc/tests/VLCTests.java b/vlc-android/test/org/videolan/vlc/util/StringsTest.java
similarity index 50%
rename from vlc-android/src/org/videolan/vlc/tests/VLCTests.java
rename to vlc-android/test/org/videolan/vlc/util/StringsTest.java
index 6c4af61..83593b8 100644
--- a/vlc-android/src/org/videolan/vlc/tests/VLCTests.java
+++ b/vlc-android/test/org/videolan/vlc/util/StringsTest.java
@@ -1,34 +1,9 @@
-package org.videolan.vlc.tests;
-
-import android.annotation.TargetApi;
-import android.os.Build;
-import android.test.ActivityInstrumentationTestCase2;
-
-import org.videolan.vlc.gui.MainActivity;
-import org.videolan.vlc.util.Strings;
-
-/**
- * Created by geoffrey on 08/05/15.
- */
-public class VLCTests extends ActivityInstrumentationTestCase2<MainActivity>{
-
-//    private MainActivity mFirstTestActivity;
-//
-//    @TargetApi(Build.VERSION_CODES.FROYO)
-//    public VLCTests(Class<MainActivity> activityClass) {
-//        super(activityClass);
-//    }
-
-    @TargetApi(Build.VERSION_CODES.FROYO)
-    public VLCTests(){
-        super(MainActivity.class);
-    }
+package org.videolan.vlc.util;
+
+import static org.junit.Assert.*;
+
+public class StringsTest {
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-//        mFirstTestActivity = getActivity();
-    }
 
     public void testGetName(){
         String path = "/home/folder/file.txt";
@@ -56,4 +31,4 @@ public class VLCTests extends ActivityInstrumentationTestCase2<MainActivity>{
         result = Strings.getParent("/folder/sub/");
         assertEquals("/folder", result);
     }
-}
+}
\ No newline at end of file



More information about the Android mailing list