Skip to content

Commit

Permalink
新增module测试
Browse files Browse the repository at this point in the history
  • Loading branch information
zhujiang521 committed Apr 27, 2020
1 parent 8d7fff4 commit a1316b8
Show file tree
Hide file tree
Showing 17 changed files with 282 additions and 3 deletions.
116 changes: 116 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ dependencies {
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(path: ':singclick')
implementation project(path: ':test')
}
3 changes: 3 additions & 0 deletions app/src/main/java/zj/it/bhne/androidaop/Main2Activity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package zj.it.bhne.androidaop;

import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
Expand All @@ -10,6 +11,7 @@

import com.blankj.utilcode.util.ToastUtils;
import com.zj.singclick.SingleClick;
import com.zj.test.TestActivity;


public class Main2Activity extends AppCompatActivity{
Expand Down Expand Up @@ -42,6 +44,7 @@ public void btnDialog(View view) {
}

public void btnStop(View view) {
startActivity(new Intent(this, TestActivity.class));
}

public void btnInter(View view) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
android:id="@+id/btnStop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="禁止点击"
android:text="跳转新包"
android:layout_gravity="center"
android:onClick="btnStop"/>

Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include ':app', ':singclick'
include ':test'
1 change: 1 addition & 0 deletions test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
38 changes: 38 additions & 0 deletions test/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
buildToolsVersion "29.0.3"

defaultConfig {
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation project(path: ':singclick')
}
Empty file added test/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions test/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
24 changes: 24 additions & 0 deletions test/src/androidTest/java/com/zj/test/ExampleInstrumentedTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.zj.test

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.zj.test.test", appContext.packageName)
}
}
9 changes: 9 additions & 0 deletions test/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zj.test">

<application>
<activity android:name=".TestActivity"></activity>
</application>

</manifest>
24 changes: 24 additions & 0 deletions test/src/main/java/com/zj/test/TestActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.zj.test

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Toast
import com.zj.singclick.SingleClick
import kotlinx.android.synthetic.main.activity_test.*

class TestActivity : AppCompatActivity(), View.OnClickListener {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_test)
btnTest.setOnClickListener(this)
}

@SingleClick
override fun onClick(v: View) {
Toast.makeText(this,"测试",Toast.LENGTH_SHORT).show()
Log.e("测试时","cee")
}
}
16 changes: 16 additions & 0 deletions test/src/main/res/layout/activity_test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".TestActivity">

<Button
android:id="@+id/btnTest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="测试"
tools:ignore="MissingConstraints" />

</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions test/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<resources></resources>
17 changes: 17 additions & 0 deletions test/src/test/java/com/zj/test/ExampleUnitTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.zj.test

import org.junit.Test

import org.junit.Assert.*

/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}

0 comments on commit a1316b8

Please sign in to comment.