是否可以使用新的Android gradle构建框架运行单个测试类?
我有一个包含多个测试类的测试包(所有测试类都是InstrumentationTestCase类).我已经能够设置我的build.gradle文件来运行测试包
defaultConfig{
testPackageName "com.company.product.tests"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
}
Run Code Online (Sandbox Code Playgroud)
但有没有办法只测试该包中的一个测试用例?否则我将使用年龄adb shell am instrument -w .......
PS我现在没有时间切换到Roboelectric,但我确实看到它现在几乎是事实上的框架.
我正在尝试在我的应用程序中使用NotificationCompat.Builder类.以下代码在ICS手机上运行得非常好,但不是姜饼.根据我的理解,支持库是否允许从低至API级别4的手机访问Builder?我做了一些根本错误的事吗?
public class MainActivity extends Activity implements OnClickListener {
NotificationCompat.Builder builder;
NotificationManager nm;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
builder = new NotificationCompat.Builder(this);
nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
builder.setContentTitle("Test Notification")
.setContentText("This is just a test notification")
.setTicker("you have been notified")
.setSmallIcon(R.drawable.ic_stat_example)
.setWhen(System.currentTimeMillis());
findViewById(R.id.btn_notify).setOnClickListener(this);
}
public void onClick(View arg0) {
// TODO Auto-generated method stub
if(arg0.getId() == R.id.btn_notify){
nm.notify(1, builder.build());
}
}
}
Run Code Online (Sandbox Code Playgroud)