Android TestCase - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android TestCase class.

This code example shows how to use the following methods: getClass, getName
            if (test instanceof TestCase) {
                TestCase testCase = (TestCase) test;
                checkForNewSuite(testCase);
                mSerializer.startTag("", TAG_CASE);
                mSerializer.attribute("", ATTRIBUTE_CLASS, mCurrentSuite);
                mSerializer.attribute("", ATTRIBUTE_NAME, testCase.getName());
 
                mTimeAlreadyWritten = false;
                mTestStartTime = System.currentTimeMillis();
            } 
        } catch (IOException e) {
            Log.e(LOG_TAG, safeMessage(e));
        } 
    } 
 
    private void checkForNewSuite(TestCase testCase) throws IOException {
        String suiteName = testCase.getClass().getName();
        if (mCurrentSuite == null || !mCurrentSuite.equals(suiteName)) {
            if (mCurrentSuite != null) {
                if (mMultiFile) {

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getClass, getName
			testKeeper.setTestname(testName);
			mTimeAlreadyWritten = false;
			mTestStartTime = System.currentTimeMillis();
			testKeeper.setStartTime(mTestStartTime);
			currentSuite.setStartTime(System.currentTimeMillis());
			testKeeper.setTest(testCase);
			checkSuiteDetails(test);
			addToSuite(test, testKeeper);
		} 
	} 
 
	private void addToSuite(Test test, TestKeeper testKeeper) {
		TestCase testcase = (TestCase) test;
		String suiteName = testcase.getClass().getName();
		HashMap<String, TestKeeper> suiteTests;
		if (suiteMap.containsKey(suiteName)) {
			suiteTests = suiteMap.get(suiteName);
		} else { 
			suiteTests = new HashMap<String, TestKeeper>();
		} 

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getClass, run
 
        while (fTests.size() != 0 && !result.shouldStop()) {
            TestCase test = (TestCase)fTests.elementAt(i);
             
            Thread.currentThread().setContextClassLoader(
                    test.getClass().getClassLoader());
 
            test.run(result);
 
            /* 
            if (fVictim != null) { 
                TestResult dummy = fVictim.run(); 
 
                if (dummy.failureCount() != 0) { 
                    result.addError(fTests.elementAt(i), new RuntimeException( 
                            "Probable side effect", 
                            ((TestFailure)dummy.failures().nextElement()). 
                            thrownException())); 
                } else if (dummy.errorCount() != 0) { 
                    result.addError(fTests.elementAt(i), new RuntimeException( 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: run, setName
            if (mTestCase instanceof DeviceTest) {
                DeviceTest deviceTest = (DeviceTest) mTestCase;
                deviceTest.setDevice(mTest.mDevice.getDevice());
                deviceTest.setTestAppPath(HostConfig.getInstance().getCaseRepository().getRoot());
            } 
            mTestCase.run(result);
        } 
        return result;
    } 
 
    /** 
     * Load test case via test class name and test method. 
     * 
     * @param testClassName The class name. 
     * @param testMethodName The method name. 
     */ 
    @SuppressWarnings("unchecked") 
    public TestCase loadTestCase(final String jarPath,
            final String testPkgName, final String testClassName,
            final String testMethodName) throws ClassNotFoundException, IOException {

5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getClass, getName
     * Checks whether the given TestCase method has the given annotation. 
     */ 
    @SuppressWarnings("unchecked") 
    boolean hasAnnotation(TestCase test, Class clazz) {
        try { 
            Method method = test.getClass().getMethod(test.getName());
            return method.getAnnotation(clazz) != null;
        } catch (Exception e) {
            // Ignore 
        } 
 
        return false; 
    } 
 
    @Override 
    @SuppressWarnings("deprecation") 
    public void runProtected(final Test test, Protectable p) {
        if ((fFlags & CoreTestSuite.DRY_RUN) == 0) {
            if (test instanceof TestCase) {
                TestCase testCase = (TestCase)test;
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android TestCase Questions & Answers:

See Code Examples for Android TestCase Methods: