空的测试套件。浓咖啡

时间:2017-10-06 05:29:13

标签: android ui-automation ui-testing android-espresso junit-runner

我是自动化测试的新手。我想运行一个特定的测试类,即使我有测试套件,它也会输出

  

"客户尚未准备好......试运行已开始......   测试结束...空测试套件.."

我搜索过并找到了很多解决方案。但他们都没有为我工作。如果我能得到任何帮助,我将不胜感激。这是测试文件。

 package com.smsbits.veridoc.activity;

@RunWith(AndroidJUnit4.class)
public class TempActivityEspressoTest {
public Resources resources;

@Rule
public ActivityTestRule mActivityRule = new ActivityTestRule<>(TempActivity.class);

@Before
public void init() {
    resources = mActivityRule.getActivity().getResources();
}

@Test
public void testCheckInputs() {
    onView(withId(R.id.btnchange)).perform(click());
    onView(withId(R.id.tvrandom)).check(ViewAssertions.matches(withText("hello")));
}} 

这是我的gradle文件。

android {  
... 
packagingOptions {
    ...
    exclude 'META-INF/XXX'
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/DEPENDENCIES'
}

defaultConfig {
    ...
    multiDexEnabled true
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

testOptions {
    unitTests.returnDefaultValues = true
}

configurations.all {
    resolutionStrategy.force 'com.android.support:support-annotations:23.0.1'
}

 }

dependencies{
...
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile "org.robolectric:robolectric:3.0"
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
    exclude group: 'javax.inject'
})
androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.2' //intents support
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
}

1 个答案:

答案 0 :(得分:0)

尝试在import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.Socket; public class Client { public void connect(String host, int port) throws Exception { System.out.println("Connecting..."); Socket socket = new Socket(host, port); System.out.println("Connected client"); ObjectInputStream ois = new ObjectInputStream(socket.getInputStream()); ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream()); System.out.println("Reading"); Game game1 = (Game) ois.readObject(); game1.printMatrix(); System.out.println("Reading"); Game game2 = (Game) ois.readObject(); game2.printMatrix(); } public static void main(String[] args) throws Exception { new Client().connect("localhost", 8082); } } https://stackoverflow.com/a/53715513/967131中手动进行新的Android Instrumented Tests配置