尝试为我的应用启动JUnit测试(robotium).
public class MainTest extends ActivityInstrumentationTestCase2<MainActivity> {
private Solo solo;
public MainTest() {
super("nix.android.contact", MainActivity.class);// TODO Auto-generated constructor stub
}
protected void setUp() throws Exception {
super.setUp();
solo = new Solo(getInstrumentation(), getActivity());
}
public void AddContact() {
solo.assertCurrentActivity("main", MainActivity.class);
}
}
Run Code Online (Sandbox Code Playgroud)
表现
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="nix.android.contact" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<uses-librar
y android:name="android.test.runner" />
</application>
Run Code Online (Sandbox Code Playgroud)
当我尝试运行测试时,进入控制台:
Test run failed: Test run failed to complete. Expected 1 tests, received 0
Run Code Online (Sandbox Code Playgroud)
我尝试为其他应用程序(非常简单的应用程序)创建其他测试 - 工作.
谢谢
我想找到存储在sdCard上的所有文件.我用过这段代码:
List<File> dir = new ArrayList<File>();
List<File> files = new ArrayList<File>();
File root = new File (Environment.getExternalStorageDirectory().getAbsolutePath());
scan(root); // find root directories
for (File f : dir) { // find in root...
scan(f);
}
Log.i("files", "" + files.size());
Log.i("dir", "" + dir.size());
}
public void scan (File path) {
for (File f : path.listFiles()) {
if (f.isFile()) {
files.add(f);
}
else {
dir.add(f);
}
}
}
Run Code Online (Sandbox Code Playgroud)
但我有这个异常的问题:"java.util.ConcurrentModificationException"我改变列表(dir)并循环它.ListIterator没有帮助.