Commit 1b490c46 by 万齐军

feat: tests改造

parent 1d69bd25
/build
\ No newline at end of file
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply from: "../../maven_push_api.gradle"
version = '1.0.0'
android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"]
buildToolsVersion rootProject.ext.android["buildToolsVersion"]
defaultConfig {
minSdkVersion rootProject.ext.android["minSdkVersion"]
targetSdkVersion rootProject.ext.android["targetSdkVersion"]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "com.alibaba:arouter-api:$arouter_api"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
\ No newline at end of file
# 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
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.ydl.tests.api">
</manifest>
\ No newline at end of file
......@@ -33,7 +33,6 @@ ext {
"ydl-net" : "0.0.3.94",
"ydl-utils" : "0.0.3.12",
//-------------- 业务模块 API 层 --------------
"m-tests-api" : "0.0.2",
"m-home-api" : "0.0.4.4",
"m-im-api" : "0.0.12.24",
]
......
......@@ -80,7 +80,7 @@ dependencies {
implementation modularPublication('com.ydl:m-im-api')
implementation project(":api:user")
implementation project(":api:dynamic")
implementation modularPublication('com.ydl:m-tests-api')
implementation project(":api:tests")
implementation project(":api:course")
implementation project(":api:fm")
implementation project(":api:consultant")
......
......@@ -79,7 +79,7 @@ dependencies {
//开发时使用
implementation project(":api:consultant")
implementation project(":api:user")
implementation modularPublication('com.ydl:m-tests-api')
implementation project(":api:tests")
implementation modularPublication('com.ydl:m-home-api')
implementation modularPublication('com.ydl:m-im-api')
implementation project(':api:confide')
......
......@@ -99,7 +99,7 @@ dependencies {
implementation modularPublication('com.ydl:m-im-api')
implementation project(":api:user")
implementation project(":api:dynamic")
implementation modularPublication('com.ydl:m-tests-api')
implementation project(":api:tests")
implementation project(":api:course")
implementation project(":api:fm")
implementation project(":api:consultant")
......
......@@ -3,14 +3,6 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'resTools' // 资源重命名插件
// 配置资源重命名插件
resConfig {
new_prefix = 'tests_' // 资源前缀
old_prefix = '' // 老前缀,可为''空字符串
}
kapt {
arguments {
arg("AROUTER_MODULE_NAME", project.getName())
......@@ -26,15 +18,6 @@ android {
targetSdkVersion rootProject.ext.android["targetSdkVersion"]
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
flavorDimensions "versionCode"
}
lintOptions {
abortOnError false
}
buildTypes {
......@@ -43,24 +26,10 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
//前缀的名字
resourcePrefix "tests_"
//Flavor 信息
publishNonDefault true
productFlavors {
ydl {}
xlzx {}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
......@@ -70,13 +39,14 @@ dependencies {
// 注意此处的依赖方式:kotlin中使用和java中使用方式有不同
kapt "com.alibaba:arouter-compiler:$arouter_compiler"
implementation project(":ydl-resource")
api rootProject.ext.dependencies["ydl-user-router"]
if (rootProject.ext.dev_mode){
//开发时使用
api project(':ydl-webview')
api project(':ydl-platform')
implementation project(':ydl-flutter-base')
implementation modularPublication('com.ydl:m-test-api')
implementation project(":api:tests")
implementation project(":api:user")
implementation project(":api:dynamic")
implementation modularPublication('com.ydl:m-im-api')
......
modular {
//模块包名
packageName "com.yidianling.tests"
// 模块发布需要的参数
publish {
modules {
xlzx {
groupId = "com.ydl"
artifactId = "m-tests-module-xlzx"
// 上报的 心理咨询 业务模块 aar 包的版本号
version = rootProject.ext.ydlPublishVersion[childProject.getName()]
}
ydl{
groupId = "com.ydl"
artifactId = "m-tests-module-ydl"
// 上报的 壹点灵 业务模块 aar 包的版本号
version = rootProject.ext.ydlPublishVersion[childProject.getName()]
}
}
api {
//壹点灵/心理咨询 业务模块 API层 jar包的发布信息
groupId = "com.ydl"
artifactId = "m-tests-api"
//开发时注释掉版本号,发布api时打开
//version = rootProject.ext.ydlPublishVersion[childProject.getName()+"-api"]
// API 层打包时需要引入的依赖
apiDependencies {
implementation "com.google.code.gson:gson:2.8.2"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.alibaba:arouter-api:1.4.1'
}
}
}
}
\ No newline at end of file
package com.yidianling.tests;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.yidianling.tests.test", appContext.getPackageName());
}
}
package com.yidianling.tests;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
String[] list1 = {"17826875951", "1782687595", "178268759", "17826875", "1782687", "178268", "17826", "1782", "178", "17", "1", "17826efdg465154",
"165e2244", "111e12345", "我的123是121223423", "我的123456789", "符合规范357545655分好尴尬", "符合规范3555分好尴尬", "订单1234", "订单12345",
"我的QQ号是3386218996", "178 2687 5951", "1q1q1q11q", "123456789a"};
String[] list2 = {"178****5951", "178****595", "178****59", "17****75", "17****7", "17****", "1****", "1782", "178", "17", "1", "1****efdg46****",
"165e2244", "111e1****", "我的123是121****23", "我的123****89", "符合规范357****55分好尴尬", "符合规范3555分好尴尬", "订单1234", "订单1****",
"我的QQ号是338****996", "178 2687 5951", "1q1q1q11q", "123****89a"};
/**
* 用于测试数字替换*的功能,功能与ios一样
*/
@Test
public void set() {
for (int tt = 0; tt < list1.length; tt++) {
String text = list1[tt];
String assertString = list2[tt];
String lastText = "";
int numberIndex = -1;
int numberCount = 0;
for (int i = 0; i < text.length(); i++) {
if (text.charAt(i) >= 48 && text.charAt(i) <= 57) {
numberIndex = i;
for (int j = i; j < text.length(); j++) {
if (text.charAt(j) >= 48 && text.charAt(j) <= 57) {
numberCount++;
if (j == text.length() - 1) {
if (numberCount >= 5) {
while (i < numberIndex + numberCount / 3) {
lastText += text.charAt(i++);
}
while (i < numberIndex + numberCount / 3 + 4) {
lastText += "*";
i++;
}
while (i <= j) {
lastText += text.charAt(i++);
}
} else {
while (i <= j) {
lastText += text.charAt(i++);
}
}
i = j;
break;
}
} else {
if (numberCount >= 5) {
while (i < numberIndex + numberCount / 3) {
lastText += text.charAt(i++);
}
while (i < numberIndex + numberCount / 3 + 4) {
lastText += "*";
i++;
}
while (i < j) {
lastText += text.charAt(i++);
}
} else {
while (i < j) {
lastText += text.charAt(i++);
}
}
i = j - 1;
numberIndex = -1;
numberCount = 0;
break;
}
}
} else {
lastText += text.charAt(i);
}
}
assertEquals(lastText, assertString);
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>
......@@ -5,4 +5,4 @@ include ':app',
':m-consultant', ':m-muse', ':m-fm', ':m-tests', ":m-course",
":m-im",":m-dynamic","m-article","m-audioim","m-user", "m-confide"
include ':ydl-tuicore', ':api:confide', ':api:dynamic', ':api:fm',':api:consultant',
':api:course',':api:user'
':api:course',':api:user',':api:tests'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment