Java Code Examples for junit.framework.Test

The following are top voted examples for showing how to use junit.framework.Test. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: incubator-netbeans   File: ExpandFolderTest.java   Source Code and License 6 votes vote down vote up
private void iterateTests(TestResult result, StringBuffer times, TestSuite suite, AtomicLong min, AtomicLong max) {
    Enumeration en = suite.tests();
    while (en.hasMoreElements()) {
        Test t = (Test)en.nextElement();
        if (t instanceof Callable) {
            try {
                Long v = (Long)((Callable) t).call();
                long time = v.longValue();
                if (time < min.longValue()) {
                    min.set(time);
                }
                if (time > max.longValue()) {
                    max.set(time);
                }
                // append(t.toString()).append(" value: ")
                times.append("Run: ").append(v).append('\n');
            } catch (Exception ex) {
                result.addError(this, ex);
            }
        }
        if (t instanceof TestSuite) {
            iterateTests(result, times, (TestSuite)t, min, max);
        }
    }
}
 
Example 2
Project: incubator-netbeans   File: TestCreationTestSuite.java   Source Code and License 6 votes vote down vote up
public static Test suite() {
    return NbModuleSuite.create(NbModuleSuite.emptyConfiguration()
            .addTest(GotoTest.class, 
                    "testSelectTestFromMainMenu",
                    "testSelectTestFromExplorer",
                    "testSelectTestFromEditorContextMenu")
            .addTest(CreateTestTest.class, 
                    "testCreateTestByPopup",
                    "testCreateTestByPopup2",
                    "testCreateTestByPopup3",
                    "testCreateTestByPopup4",
                    "testCreateTestByWizard",
                    "testCreateWODefMethodBodies",
                    "testCreateWOHints",
                    "testCreateWOJavadoc",
                    "testCreateWOsetUp",
                    "testCreateWOtearDown",
                    "testCreateTestAndSuiteByPopup",
                    "testCreateTestAndSuiteByPopup2",
                    "testCreateIntegrationTestAndSuiteByPopup")
            .enableModules(".*").clusters(".*"));
}
 
Example 3
Project: googles-monorepo-demo   File: TestsForListsInJavaUtil.java   Source Code and License 6 votes vote down vote up
public Test testsForSingletonList() {
  return ListTestSuiteBuilder.using(
          new TestStringListGenerator() {
            @Override
            public List<String> create(String[] elements) {
              return Collections.singletonList(elements[0]);
            }
          })
      .named("singletonList")
      .withFeatures(
          CollectionFeature.SERIALIZABLE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionSize.ONE)
      .suppressing(suppressForSingletonList())
      .createTestSuite();
}
 
Example 4
Project: incubator-netbeans   File: NbModuleSuiteTest.java   Source Code and License 6 votes vote down vote up
public void testTwoClassesAtOnce() throws Exception {
    System.setProperty("ins.one", "No");
    System.setProperty("ins.two", "No");
    System.setProperty("ins.three", "No");
    System.setProperty("en.one", "No");

    NbModuleSuite.Configuration config = NbModuleSuite.Configuration.create(
        AskForOrgOpenideUtilEnumClass.class
    ).enableModules("org.openide.util.enumerations").gui(false)
    .addTest(NbModuleSuiteIns.class, "testSecond");
    Test instance = config.suite();
    junit.textui.TestRunner.run(instance);

    assertProperty("en.one", "OK");
    assertProperty("ins.one", "No");
    assertProperty("ins.two", "OK");
    assertProperty("ins.three", "No");
}
 
Example 5
Project: guava-mock   File: SetsTest.java   Source Code and License 6 votes vote down vote up
@GwtIncompatible // suite
private static Test testsForFilter() {
  return SetTestSuiteBuilder.using(new TestStringSetGenerator() {
        @Override public Set<String> create(String[] elements) {
          Set<String> unfiltered = Sets.newLinkedHashSet();
          unfiltered.add("yyy");
          Collections.addAll(unfiltered, elements);
          unfiltered.add("zzz");
          return Sets.filter(unfiltered, Collections2Test.NOT_YYY_ZZZ);
        }
      })
      .named("Sets.filter")
      .withFeatures(
          CollectionFeature.SUPPORTS_ADD,
          CollectionFeature.SUPPORTS_REMOVE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionFeature.KNOWN_ORDER,
          CollectionSize.ANY)
      .createTestSuite();
}
 
Example 6
Project: sstore-soft   File: VoltJUnitFormatter.java   Source Code and License 6 votes vote down vote up
@Override
public void addError(Test arg0, Throwable arg1) {
    String testName = "unknown";
    if (arg0 != null) {
        testName = arg0.toString();
        int idx = testName.indexOf('(');
        if (idx > 0) { 
            testName = testName.substring(0, idx);
        }
    }

    out.println("    " + testName + " had an error.");
    StackTraceElement[] st = arg1.getStackTrace();
    int i = 0;
    for (StackTraceElement ste : st) {
        if (ste.getClassName().contains("org.voltdb") == false)
            continue;
        out.printf("        %s(%s:%d)\n", ste.getClassName(), ste.getFileName(), ste.getLineNumber());
        if (++i == 3) break;
    }
    m_errs++;
}
 
Example 7
Project: googles-monorepo-demo   File: TestsForListsInJavaUtil.java   Source Code and License 6 votes vote down vote up
public Test testsForArraysAsList() {
  return ListTestSuiteBuilder.using(
          new TestStringListGenerator() {
            @Override
            public List<String> create(String[] elements) {
              return Arrays.asList(elements.clone());
            }
          })
      .named("Arrays.asList")
      .withFeatures(
          ListFeature.SUPPORTS_SET,
          CollectionFeature.SERIALIZABLE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionSize.ANY)
      .suppressing(suppressForArraysAsList())
      .createTestSuite();
}
 
Example 8
Project: incubator-netbeans   File: hgStableTest.java   Source Code and License 6 votes vote down vote up
public static Test suite() {
        if (hgExistsChecker.check(false)) {
            return NbModuleSuite.create(NbModuleSuite.emptyConfiguration()
                    .addTest(InitializeTest.class, "testInitializeAndFirstCommit")
                    .addTest(CommitDataTest.class, "testCommitFile", "testRecognizeMimeType")
//                    .addTest(CommitUiTest.class, "testInvokeCloseCommit")
                    .addTest(IgnoreTest.class, "testIgnoreUnignoreFile")
//                    .addTest(DeleteUpdateTest.class, "testDeleteUpdate")
                    .addTest(AnnotationsTest.class, "testShowAnnotations")
                    .addTest(HgPropertiesTest.class, "testHgPropertiesTest")
                    .addTest(CloneTest.class, "testCloneProject")
                    .enableModules(".*")
                    .clusters(".*"));
        } else {
            return NbModuleSuite.create(NbModuleSuite.emptyConfiguration());
        }
    }
 
Example 9
Project: marathonv5   File: TestRunner.java   Source Code and License 6 votes vote down vote up
public Result doRun(Test suite, boolean wait) {
    MarathonTestRunner runner = new MarathonTestRunner();
    runReportDir = argProcessor.getReportDir();
    String resultsDir = new File(runReportDir, "results").getAbsolutePath();
    if (runReportDir != null) {
        System.setProperty(Constants.PROP_REPORT_DIR, runReportDir);
        System.setProperty(Constants.PROP_IMAGE_CAPTURE_DIR, runReportDir);
        System.setProperty("allure.results.directory", resultsDir);
        runner.addListener(new AllureMarathonRunListener());
    }
    runner.addListener(new TextListener(System.out));
    Result result = runSuite(suite, runner);
    MarathonTestCase.reset();
    if (runReportDir != null && !argProcessor.isSkipreports()) {
        AllureUtils.launchAllure(false, resultsDir, new File(runReportDir, "reports").getAbsolutePath());
    }
    return result;
}
 
Example 10
Project: guava-mock   File: Collections2Test.java   Source Code and License 6 votes vote down vote up
@GwtIncompatible // suite
private static Test testsForFilter() {
  return CollectionTestSuiteBuilder.using(
      new TestStringCollectionGenerator() {
        @Override public Collection<String> create(String[] elements) {
          List<String> unfiltered = newArrayList();
          unfiltered.add("yyy");
          Collections.addAll(unfiltered, elements);
          unfiltered.add("zzz");
          return Collections2.filter(unfiltered, NOT_YYY_ZZZ);
        }
      })
      .named("Collections2.filter")
      .withFeatures(
          CollectionFeature.SUPPORTS_ADD,
          CollectionFeature.SUPPORTS_REMOVE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionFeature.KNOWN_ORDER,
          CollectionSize.ANY)
      .createTestSuite();
}
 
Example 11
Project: guava-mock   File: TestsForSetsInJavaUtil.java   Source Code and License 6 votes vote down vote up
public Test testsForSingletonSet() {
  return SetTestSuiteBuilder.using(
          new TestStringSetGenerator() {
            @Override
            public Set<String> create(String[] elements) {
              return Collections.singleton(elements[0]);
            }
          })
      .named("singleton")
      .withFeatures(
          CollectionFeature.SERIALIZABLE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionSize.ONE)
      .suppressing(suppressForSingletonSet())
      .createTestSuite();
}
 
Example 12
Project: incubator-netbeans   File: WatchesTestSuite.java   Source Code and License 6 votes vote down vote up
public static Test suite() {
//        String os = System.getProperty("os.name");
//        String jdk = System.getProperty("java.version");
//        if ( jdk.contains("1.5") && os.contains("Windows") && !os.contains("Vista") ) {
//            return NbModuleSuite.create(NbModuleSuite.emptyConfiguration());
//        } else {
            return NbModuleSuite.create(NbModuleSuite.emptyConfiguration()
                .addTest(WatchesTest.class,
                    "testWatchesPublicVariables",
                    "testWatchesProtectedVariables",
                    "testWatchesPrivateVariables",
                    "testWatchesPackagePrivateVariables",
                    "testWatchesFiltersBasic",
                    "testWatchesFiltersLinkedList",
                    "testWatchesFiltersArrayList",
                    "testWatchesFiltersVector",
                    "testWatchesFiltersHashMap",
                    "testWatchesFiltersHashtable",
                    "testWatchesFiltersTreeMap",
                    "testWatchesFiltersTreeSet",
                    "testWatchesFilters1DArray",
                    "testWatchesFilters2DArray",
                    "testWatchesValues").enableModules(".*").clusters(".*"));
//        }
    }
 
Example 13
Project: incubator-netbeans   File: Breakpoints_MethodTestSuite.java   Source Code and License 6 votes vote down vote up
public static Test suite() {
//        String os = System.getProperty("os.name");
//        String jdk = System.getProperty("java.version");
//        if ( jdk.contains("1.5") && os.contains("Windows") && !os.contains("Vista") ) {
//            return NbModuleSuite.create(NbModuleSuite.emptyConfiguration());
//        } else {
            return NbModuleSuite.create(NbModuleSuite.emptyConfiguration()
                .addTest(MethodBreakpointsTest.class,
                    "testMethodBreakpointCreation",
                    "testMethodBreakpointPrefilledConstructor",
                    "testMethodBreakpointPrefilledMethod",
                    "testMethodBreakpointCreation",
                    "testMethodBreakpointFunctionalityInPrimaryClass",
                    "testMethodBreakpointFunctionalityInSecondClass",
                    "testMethodBreakpointFunctionalityOnAllMethods",
                    "testMethodBreakpointFunctionalityOnExit",
                    "testConditionalMethodBreakpointFunctionality",
                    "testMethodBreakpointsValidation"
                )
            .enableModules(".*").clusters(".*"));
//        }
    }
 
Example 14
Project: marathonv5   File: TestCreator.java   Source Code and License 5 votes vote down vote up
public Test getGroup(GroupType type, String groupName) throws IOException {
    File file = getGroupFile(type, groupName);
    if (file == null) {
        return null;
    }
    TestSuite testSuite = getTest(Group.findByFile(type, file.toPath()));
    return testSuite;
}
 
Example 15
Project: incubator-netbeans   File: NbModuleSuiteTest.java   Source Code and License 5 votes vote down vote up
public void testAccessToInsaneAndFSWithAllModulesEnumerated() {
    System.setProperty("ins.one", "no");
    System.setProperty("ins.fs", "no");

    Test instance = NbModuleSuite.createConfiguration(NbModuleSuiteIns.class).
            gui(false).clusters(".*").enableModules(".*").addTest("testFS").suite();
    junit.textui.TestRunner.run(instance);

    assertProperty("ins.one", "no");
    assertProperty("ins.fs", "OK");
}
 
Example 16
Project: incubator-netbeans   File: svnPropertiesTestSuite.java   Source Code and License 5 votes vote down vote up
/**
 * Simple method uniting together all the different tests under subversion
 * tests-qa-functional
 */
public static Test suite() {
    if (svnExistsChecker.check(false)) {
        return NbModuleSuite.create(NbModuleSuite.emptyConfiguration()
                .addTest(SvnPropertiesTest.class, "propTest")
                .enableModules(".*").clusters(".*"));
    } else {
        return NbModuleSuite.create(NbModuleSuite.emptyConfiguration());
    }
}
 
Example 17
Project: incubator-netbeans   File: NbModuleSuiteOrderTest.java   Source Code and License 5 votes vote down vote up
public void testStaticOrder(){
    System.setProperty("order", "1");
    String[] methods = new String[]{"testTwo", "testOne"};
    Test instance = NbModuleSuite.createConfiguration(TT2.class).clusters(".*").enableModules(".*").gui(false).addTest(methods).suite();
    junit.textui.TestRunner.run(instance);

    NbModuleSuiteTest.assertProperty("t.two", "2");
    NbModuleSuiteTest.assertProperty("t.one", "3");
    NbModuleSuiteTest.assertProperty(TEST_ORDER_COUNTER, "3");
}
 
Example 18
Project: incubator-netbeans   File: IssuetableTestFactory.java   Source Code and License 5 votes vote down vote up
private static IssuetableTestFactory getFromMap (Test test) {
    LinkedList s = (LinkedList) map.get (test);
    IssuetableTestFactory  retVal;
    try {
        retVal = (IssuetableTestFactory) s.getLast();
    } catch (NoSuchElementException x ) {
        System.out.println("exc: "+ test + " : " );
        throw x;
    }
    return retVal;
}
 
Example 19
Project: incubator-netbeans   File: NbModuleSuiteTest.java   Source Code and License 5 votes vote down vote up
public void testAccessExtraDefinedAutoload() {
    System.setProperty("en.one", "No");

    NbModuleSuite.Configuration config = NbModuleSuite.Configuration.create(AskForOrgOpenideUtilEnumClass.class);
    NbModuleSuite.Configuration addEnum = config.enableModules("org.openide.util.enumerations");
    Test instance = addEnum.gui(false).suite();
    junit.textui.TestRunner.run(instance);

    assertEquals("OK", System.getProperty("en.one"));
}
 
Example 20
Project: incubator-netbeans   File: CachingAndExternalURLTest.java   Source Code and License 5 votes vote down vote up
public static Test suite() throws IOException {
    return CachingAndExternalPathsTest.create(new CachingAndExternalPathsTest.SetExtDirProperty() {
        public void setExtDirProperty(File value) {
            System.setProperty("ext.dir", Utilities.toURI(value).toString());
        }
    });
}
 
Example 21
Project: incubator-netbeans   File: DiffTest.java   Source Code and License 5 votes vote down vote up
public static Test suite() {
    return NbModuleSuite.create(NbModuleSuite.createConfiguration(DiffTest.class)
            .addTest("testDiffFile")
            .enableModules(".*")
            .clusters(".*")
    );
}
 
Example 22
Project: incubator-netbeans   File: NetigsoLayerTest.java   Source Code and License 5 votes vote down vote up
public static Test suite() {
        Test t = null;
//        t = new NetigsoTest("testOSGiCanRequireBundleOnNetBeans");
        if (t == null) {
            t = new NbTestSuite(NetigsoLayerTest.class);
        }
        return t;
    }
 
Example 23
Project: vogar   File: Junit3.java   Source Code and License 5 votes vote down vote up
public static boolean isJunit3Test(Class<?> klass) {
    // public class FooTest extends TestCase {...}
    //   or
    // public class FooSuite {
    //    public static Test suite() {...}
    // }
    return (TestCase.class.isAssignableFrom(klass) && !Modifier.isAbstract(klass.getModifiers()))
            || new ClassAnalyzer(klass).hasMethod(true, Test.class, "suite");
}
 
Example 24
Project: incubator-netbeans   File: BasicTest.java   Source Code and License 5 votes vote down vote up
public static Test suite() {
    return NbModuleSuite.create(
        NbModuleSuite.createConfiguration(BasicTest.class).addTest(
        "testBasic",
        "testBasicCPU",
        "testBasicMemory",
        "testCascadeThreads",
        "testCascadeThreadsCPU",
        "testCascadeThreadsMemory").enableModules(".*").clusters(".*").gui(false));
}
 
Example 25
Project: googles-monorepo-demo   File: TestsForSetsInJavaUtil.java   Source Code and License 5 votes vote down vote up
public Test testsForAbstractSet() {
  return SetTestSuiteBuilder.using(
          new TestStringSetGenerator() {
            @Override
            protected Set<String> create(String[] elements) {
              final String[] deduped = dedupe(elements);
              return new AbstractSet<String>() {
                @Override
                public int size() {
                  return deduped.length;
                }

                @Override
                public Iterator<String> iterator() {
                  return MinimalCollection.of(deduped).iterator();
                }
              };
            }
          })
      .named("AbstractSet")
      .withFeatures(
          CollectionFeature.NONE,
          CollectionFeature.ALLOWS_NULL_VALUES,
          CollectionFeature.KNOWN_ORDER, // in this case, anyway
          CollectionSize.ANY)
      .suppressing(suppressForAbstractSet())
      .createTestSuite();
}
 
Example 26
Project: incubator-netbeans   File: BasicTest.java   Source Code and License 5 votes vote down vote up
public static Test suite() {
    return NbModuleSuite.create(NbModuleSuite.createConfiguration(BasicTest.class).addTest(
           "testBasicIndentation",
           "testAdvancedIndentation",
           "testReformat",
           "testReformat2"
           ).clusters(".*").enableModules(".*").gui(true));

}
 
Example 27
Project: incubator-netbeans   File: HTMLNodeTest.java   Source Code and License 4 votes vote down vote up
/** method used for explicit testsuite definition
 */
public static Test suite() {
    return createModuleTest(HTMLNodeTest.class, tests);
}
 
Example 28
Project: jaffa-framework   File: RawTest.java   Source Code and License 4 votes vote down vote up
/** Assembles and returns a test suite containing all known tests.
 * @return A test suite.
 */
public static Test suite() {
    return new Wrapper(new TestSuite(RawTest.class));
}
 
Example 29
Project: incubator-netbeans   File: PatternsTest.java   Source Code and License 4 votes vote down vote up
public static Test suite() {
    return NbModuleSuite.create(
            NbModuleSuite.createConfiguration(PatternsTest.class)
            .enableModules(".*")
            .clusters(".*"));
}
 
Example 30
Project: incubator-netbeans   File: NewFileWizardOperatorTest.java   Source Code and License 4 votes vote down vote up
/** Method used for explicit testsuite definition
 * @return  created suite
 */
public static Test suite() {
    return createModuleTest(NewFileWizardOperatorTest.class,
            tests);
}
 
Example 31
Project: ConfigCenter   File: AppTest.java   Source Code and License 4 votes vote down vote up
/**
 * @return the suite of tests being tested
 */
public static Test suite()
{
    return new TestSuite( AppTest.class );
}
 
Example 32
Project: jaffa-framework   File: StoredProcedureTest.java   Source Code and License 4 votes vote down vote up
/** Assembles and returns a test suite containing all known tests.
 * @return A test suite.
 */
public static Test suite() {
    return new Wrapper(new TestSuite(StoredProcedureTest.class));
}
 
Example 33
Project: incubator-netbeans   File: QuickSearchTest.java   Source Code and License 4 votes vote down vote up
public static Test suite() {
    return GraphicsEnvironment.isHeadless() ? new TestSuite() : new TestSuite(QuickSearchTest.class);
}
 
Example 34
Project: incubator-netbeans   File: DiffTest.java   Source Code and License 4 votes vote down vote up
public static Test suite() {
    return NbModuleSuite.create(
            NbModuleSuite.createConfiguration(DiffTest.class).addTest(
            "testDiffFile"
            ).enableModules(".*").clusters(".*"));
}
 
Example 35
Project: hlxy-docker   File: AppTest.java   Source Code and License 4 votes vote down vote up
/**
 * @return the suite of tests being tested
 */
public static Test suite()
{
    return new TestSuite( AppTest.class );
}
 
Example 36
Project: incubator-netbeans   File: ThreadBreakpointTest.java   Source Code and License 4 votes vote down vote up
public static Test suite() {
    return JPDASupport.createTestSuite(ThreadBreakpointTest.class);
}
 
Example 37
Project: myfaces-trinidad   File: HtmlFrameBorderLayoutTest.java   Source Code and License 4 votes vote down vote up
public static Test suite()
{
  return new TestSuite(HtmlFrameBorderLayoutTest.class);
}
 
Example 38
Project: lib-commons-httpclient   File: TestCookieVersionSupport.java   Source Code and License 4 votes vote down vote up
public static Test suite() {
    return new TestSuite(TestCookieVersionSupport.class);
}
 
Example 39
Project: openjdk-jdk10   File: EntryTest.java   Source Code and License 4 votes vote down vote up
public static Test suite() {
    return new TestSuite(EntryTest.class);
}
 
Example 40
Project: incubator-netbeans   File: SmartCCTests.java   Source Code and License 4 votes vote down vote up
public static Test suite() {
    return NbModuleSuite.create(
            NbModuleSuite.createConfiguration(SmartCCTests.class).enableModules(".*").clusters(".*"));
}