Skip to content

Commit

Permalink
Separate testing infrastructure into it's own module.
Browse files Browse the repository at this point in the history
  • Loading branch information
vanniktech committed Feb 23, 2019
1 parent 2941ede commit 2be3a0f
Show file tree
Hide file tree
Showing 23 changed files with 57 additions and 9 deletions.
31 changes: 31 additions & 0 deletions rxpermission-testing/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apply plugin: 'com.android.library'

afterEvaluate {
generateReleaseBuildConfig.enabled = false
}

android {
compileSdkVersion versions.compileSdk

defaultConfig {
minSdkVersion versions.minSdk
}

resourcePrefix 'rx_permission_mock_'

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}

dependencies {
api project(":rxpermission")
}

dependencies {
testImplementation deps.test.junit
testImplementation deps.test.assertj3
}

apply plugin: "com.vanniktech.maven.publish"
3 changes: 3 additions & 0 deletions rxpermission-testing/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POM_NAME=RxPermission Testing
POM_ARTIFACT_ID=rxpermission-testing
POM_PACKAGING=aar
1 change: 1 addition & 0 deletions rxpermission-testing/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<manifest package="com.vanniktech.rxpermission.testing"/>
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.vanniktech.rxpermission;
package com.vanniktech.rxpermission.testing;

import com.vanniktech.rxpermission.Permission;
import com.vanniktech.rxpermission.RxPermission;
import io.reactivex.Observable;
import io.reactivex.Single;
import io.reactivex.annotations.CheckReturnValue;
Expand All @@ -9,7 +11,7 @@

import static com.vanniktech.rxpermission.Permission.State.GRANTED;
import static com.vanniktech.rxpermission.Permission.State.REVOKED_BY_POLICY;
import static com.vanniktech.rxpermission.Utils.checkPermissions;
import static com.vanniktech.rxpermission.testing.Utils.checkPermissions;

/**
* Mocking class that can be used for unit testing.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.vanniktech.rxpermission.testing;

final class Utils {
static void checkPermissions(final String[] permissions) {
if (permissions == null || permissions.length == 0) {
throw new IllegalArgumentException("permissions are null or empty");
}
}

private Utils() {
throw new AssertionError("No instances.");
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package com.vanniktech.rxpermission;
package com.vanniktech.rxpermission.testing;

import android.annotation.SuppressLint;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import static android.Manifest.permission.CALL_PHONE;
import static android.Manifest.permission.CAMERA;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.junit.Assert.fail;

public final class MockRxPermissionTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();

private Permission callPhoneGranted;

private Permission cameraGranted;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ android {
}

dependencies {
implementation project(':library')
implementation project(':rxpermission')

implementation deps.support.appCompat
}
3 changes: 2 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include ':library'
include ':rxpermission'
include ':rxpermission-testing'
include ':sample'

0 comments on commit 2be3a0f

Please sign in to comment.