diff --git a/entry/build.gradle b/entry/build.gradle index a9a67ed4ec4e115984cba7004437b14f3a577943..5138d8454eb91a3e81325f90b0883a025a7954b9 100644 --- a/entry/build.gradle +++ b/entry/build.gradle @@ -1,4 +1,6 @@ apply plugin: 'com.huawei.ohos.hap' +apply plugin: 'com.huawei.ohos.decctest' + ohos { compileSdkVersion 5 defaultConfig { @@ -8,7 +10,9 @@ ohos { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) - testCompile 'junit:junit:4.12' + testImplementation 'junit:junit:4.13' + ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100' + implementation 'io.reactivex.rxjava2:rxjava:2.2.5' implementation 'com.squareup.retrofit2:converter-gson:2.5.0' implementation 'com.squareup.retrofit2:adapter-rxjava2:2.5.0' diff --git a/entry/src/main/java/ua/naiksoftware/stompclientexample/SimpleAdapter.java b/entry/src/main/java/ua/naiksoftware/stompclientexample/SimpleAdapter.java index 4bd6c3e7ef275990bb540c5970ad87c95aa80e02..f13f009338a9bb38d7cca026682c6baba7915f38 100644 --- a/entry/src/main/java/ua/naiksoftware/stompclientexample/SimpleAdapter.java +++ b/entry/src/main/java/ua/naiksoftware/stompclientexample/SimpleAdapter.java @@ -79,4 +79,4 @@ public class SimpleAdapter extends BaseItemProvider { private static class ViewHolder { Text title; } -} \ No newline at end of file +} diff --git a/entry/src/ohosTest/config.json b/entry/src/ohosTest/config.json new file mode 100644 index 0000000000000000000000000000000000000000..337318879f74df8d28417dd320e5c41611536c37 --- /dev/null +++ b/entry/src/ohosTest/config.json @@ -0,0 +1,47 @@ +{ + "app": { + "bundleName": "ua.naiksoftware.stompclientexample", + "vendor": "naiksoftware", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 5, + "target": 5, + "releaseType": "Release" + } + }, + "deviceConfig": {}, + "module": { + "package": "ua.naiksoftware.stompclientexample", + "name": "testModule", + "deviceType": [ + "phone" + ], + "reqPermissions": [ + { + "name": "ohos.permission.INTERNET" + } + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry_test", + "moduleType": "feature", + "installationFree": true + }, + "abilities": [ + { + "originalName": "unspecified", + "name": "ua.naiksoftware.stompclientexample.MainAbility", + "description": "Test Entry Ability", + "icon": "$media:icon", + "label": "", + "launchType": "standard", + "orientation": "landscape", + "visible": true, + "type": "page" + } + ] + } +} \ No newline at end of file diff --git a/entry/src/ohosTest/java/ua/naiksoftware/stompclientexample/ExampleOhosTest.java b/entry/src/ohosTest/java/ua/naiksoftware/stompclientexample/ExampleOhosTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c35715a1a0102e64353652a537214303e9a3e4d2 --- /dev/null +++ b/entry/src/ohosTest/java/ua/naiksoftware/stompclientexample/ExampleOhosTest.java @@ -0,0 +1,57 @@ +package ua.naiksoftware.stompclientexample; + +import io.reactivex.Completable; +import io.reactivex.Observable; +import org.junit.Test; +import ua.naiksoftware.stomp.StompClient; +import ua.naiksoftware.stomp.dto.LifecycleEvent; +import ua.naiksoftware.stomp.provider.ConnectionProvider; + + +public class ExampleOhosTest { + // 不涉及 测试报告生成异常 + StompClient client = new StompClient(new ConnectionProvider() { + @Override + public Observable messages() { + return null; + } + + @Override + public Completable send(String stompMessage) { + return null; + } + + @Override + public Observable lifecycle() { + return null; + } + + @Override + public Completable disconnect() { + return null; + } + }); + @Test + public void connect() { + client.connect(); + } + + @Test + public void lifecycle() { + client.lifecycle(); + } + + @Test + public void disconnect() { + client.disconnect(); + } + + @Test + public void disconnectCompletable() { + client.disconnectCompletable(); + } + @Test + public void reconnect(){ + client.reconnect(); + } +} \ No newline at end of file diff --git a/entry/src/test/java/ua/naiksoftware/stompclientexample/ExampleTest.java b/entry/src/test/java/ua/naiksoftware/stompclientexample/ExampleTest.java index edbdd3e2eb5f2dca63700524987488b8b2bf5f74..e62188cfe15c3f5be9391f48fe53a241a5b5ea88 100644 --- a/entry/src/test/java/ua/naiksoftware/stompclientexample/ExampleTest.java +++ b/entry/src/test/java/ua/naiksoftware/stompclientexample/ExampleTest.java @@ -6,6 +6,9 @@ import ua.naiksoftware.stomp.StompClient; import static org.mockito.Mockito.mock; public class ExampleTest { + + + StompClient client = mock(StompClient.class); @Test @@ -32,6 +35,4 @@ public class ExampleTest { client.reconnect(); } - public void cos(){ - } }