Source:
<code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); trs = TestResultStorage.getInstance(); mAdapter = new ArrayAdapter<TestResults>(this,R.layout.list_view_text); if(savedInstanceState != null || trs.size() > 0){ testsRan = true; mAdapter.addAll(trs.getAll()); } this.setListAdapter(mAdapter); Thread thread = new Thread(new Runnable() { @Override public void run() { CloudantListener listner = new CloudantListener(); JUnitCore core = new JUnitCore(); core.addListener(listner); <START> Class[] excludeCategories = {RequireRunningCouchDB.class, PerformanceTest.class, SystemTest.class}; <END> ArrayList<Class> classes = new ArrayList<Class>(); for(Class c:BuildConfig.classToTests){ boolean excluded = false; for(Class excludes:excludeCategories) { if(excludes.equals(c)) { excluded = true; break; } } if(!excluded){ classes.add(c); } } Filter filter = new Categories.CategoryFilter(null, null); for(Class c : excludeCategories) { filter = filter.intersect(new Categories.CategoryFilter(null, c)); } Request request = Request.classes(classes.toArray(new Class[classes.size()])).filterWith(filter); final Result r = core.run(request); testsRan = true; final List<Failure> failures = r.getFailures(); runOnUiThread(new Runnable() { @Override public void run() { for (Failure f : failures) { TestResults tr = new TestResults(f); trs.add(tr); mAdapter.add(tr); } } }); JUnitXMLFormatter xmlFormatter = new JUnitXMLFormatter(); try { xmlFormatter.outputResults(listner.getCompeltedTests()); } catch (IOException e) { e.printStackTrace(); } catch (TransformerException e) { e.printStackTrace(); } catch (Exception e){ e.printStackTrace(); } } }); if(!testsRan) { thread.start(); } }</code><technical_language>pass categories in gradle tasks similar in sync-core: test, integrationTest, performanceTest, systemTest</technical_language>

Target:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); System.setProperty( "dexmaker.dexcache", this.getCacheDir().getPath() ); trs = TestResultStorage.getInstance(); mAdapter = new ArrayAdapter<TestResults>(this,R.layout.list_view_text); if(savedInstanceState != null || trs.size() > 0){ testsRan = true; mAdapter.addAll(trs.getAll()); } this.setListAdapter(mAdapter); Thread thread = new Thread(new Runnable() { @Override public void run() { CloudantListener listener = new CloudantListener(); JUnitCore core = new JUnitCore(); core.addListener(listener); ArrayList<Class> classes = new ArrayList<Class>(); for(Class c:BuildConfig.classToTests){ classes.add(c); } Filter filter = new Categories.CategoryFilter(null, null); for(Class c : BuildConfig.testExcludes) { filter = filter.intersect(new Categories.CategoryFilter(null, c)); } Request request = Request.classes(classes.toArray(new Class[classes.size()])).filterWith(filter); final Result r = core.run(request); testsRan = true; final List<Failure> failures = r.getFailures(); runOnUiThread(new Runnable() { @Override public void run() { if(failures.size() == 0){ ArrayAdapter<String> adapter = new ArrayAdapter<String>(ctx,R.layout.list_view_text); ctx.setListAdapter(adapter); adapter.add("No Failures"); adapter.add("Ran "+r.getRunCount()+" tests"); }else { for (Failure f : failures) { if (f.getTestHeader().contains("initializationError(")) continue; TestResults tr = new TestResults(f); trs.add(tr); mAdapter.add(tr); } } } }); JUnitXMLFormatter xmlFormatter = new JUnitXMLFormatter(); try { xmlFormatter.outputResults(listener.getCompletedTests()); } catch (IOException e) { e.printStackTrace(); } catch (TransformerException e) { e.printStackTrace(); } catch (Exception e){ e.printStackTrace(); } } }); if(!testsRan) { thread.start(); } }