Package com.google.jstestdriver.embedded

Examples of com.google.jstestdriver.embedded.JsTestDriverBuilder


      if (instance != null && instance.getPort() != port) {
        instance.stop();
        instance = null;
      }
      if (instance == null) {
        JsTestDriver jstd = new JsTestDriverBuilder()
            .setDefaultConfiguration(new EclipseServerConfiguration())
            .raiseExceptionOnTestFailure(false)
            .addServerListener(jstdServerListener)
            .setRunnerMode(RunnerMode.DEBUG)
            .setPort(port).build();
View Full Code Here


*/
public class JstdTestRunner {
  ProjectHelper helper = new ProjectHelper();

  private JsTestDriver getJstd(BasePaths basePaths) throws CoreException {
    JsTestDriverBuilder builder = new JsTestDriverBuilder()
        .setServer(ServiceLocator.getService(ServerController.class).getServerUrl())
        .setRunnerMode(RunnerMode.DEBUG)
        .addBasePaths(basePaths)
        .raiseExceptionOnTestFailure(false)
        .setDefaultConfiguration(new EclipseServerConfiguration());

    for (TestListener listener : ServiceLocator.getExtensionPoints(TestListener.class,
        "com.google.jstestdriver.hooks.TestListener")) {
      builder.addTestListener(listener);
    }
    return builder.build();
  }
View Full Code Here

  public void testServerStartAndStop() throws Exception {
    CountDownLatch startLatch = new CountDownLatch(1);
    CountDownLatch stopLatch = new CountDownLatch(1);
    TestListener testServerListener = new TestListener(startLatch, stopLatch);
    JsTestDriver jstd = new JsTestDriverBuilder()
        .setDefaultConfiguration(new TestConfiguration(new File(".")))
        .setRunnerMode(RunnerMode.DEBUG)
        .addServerListener(testServerListener)
        .setPort(8081)
        .build();
View Full Code Here

 
  public void a_testDryRun() throws Exception {
    CountDownLatch startLatch = new CountDownLatch(1);
    CountDownLatch stopLatch = new CountDownLatch(1);
    TestListener testServerListener = new TestListener(startLatch, stopLatch);
    JsTestDriver jstd = new JsTestDriverBuilder()
        .setDefaultConfiguration(new TestConfiguration(new File(".")))
        .setRunnerMode(RunnerMode.DEBUG)
        .addServerListener(testServerListener)
        .setPort(8082)
        .build();
View Full Code Here

    }
  }

  @SuppressWarnings("deprecation")
  private void runTests(@NotNull final File configFile, @NotNull String[] extraArgs, final boolean dryRun) throws ConfigurationException {
    JsTestDriverBuilder builder = new JsTestDriverBuilder();

    final ParsedConfiguration parsedConfiguration;
    try {
      parsedConfiguration = JstdConfigParsingUtils.parseConfiguration(configFile);
    } catch (Exception e) {
      throw new ConfigurationException("Configuration file parsing failed.\n" +
                                       "See http://code.google.com/p/js-test-driver/wiki/ConfigurationFile for clarification.\n\n" +
                                       "Details:", e);
    }
    final File singleBasePath = JstdConfigParsingUtils.getSingleBasePath(parsedConfiguration.getBasePaths(), configFile);
    myTreeManager.setCurrentBasePath(singleBasePath.getAbsolutePath());
    JstdConfigParsingUtils.wipeCoveragePlugin(parsedConfiguration);
    builder.setDefaultConfiguration(parsedConfiguration);
    builder.withPluginInitializer(new PluginInitializer() {
      @Override
      public Module initializeModule(Flags flags, Configuration config) {
        return new AbstractModule() {
          @Override
          public void configure() {
            Multibinder<TestListener> testListeners = Multibinder.newSetBinder(binder(), TestListener.class);
            testListeners.addBinding().to(TestResultHolder.class);
            testListeners.addBinding().toInstance(new IdeaTestListener(
              myTreeManager,
              configFile,
              singleBasePath,
              dryRun,
              mySettings.getTestFileScope()
            ));
          }
        };
      }
    });

    builder.setRunnerMode(RunnerMode.QUIET);
    builder.setServer(mySettings.getServerUrl());

    List<String> flagArgs = Lists.newArrayList("--captureConsole", "--server", mySettings.getServerUrl());
    ResolvedConfiguration resolvedConfiguration = JstdConfigParsingUtils.resolveConfiguration(parsedConfiguration);
    if (dryRun && JstdUtils.isJasmineTests(resolvedConfiguration)) {
      // https://github.com/ibolmo/jasmine-jstd-adapter/pull/21
      flagArgs.add("--reset");
    }
    flagArgs.addAll(Arrays.asList(extraArgs));
    List<String> coverageExcludedFiles = null;
    File emptyOutputDir = null;
    boolean runCoverage = false;
    if (myCoverageSession != null && !dryRun) {
      emptyOutputDir = createTempDir();
      if (emptyOutputDir != null) {
        flagArgs.add("--testOutput");
        flagArgs.add(emptyOutputDir.getAbsolutePath());
        List<String> testPaths = getTestFilePaths(resolvedConfiguration);
        coverageExcludedFiles = Lists.newArrayList(testPaths);
        coverageExcludedFiles.addAll(mySettings.getFilesExcludedFromCoverageRec());
        PluginInitializer coverageInitializer = getCoverageInitializer(coverageExcludedFiles);
        if (coverageInitializer != null) {
          builder.withPluginInitializer(coverageInitializer);
          builder.withPluginInitializer(new DependenciesTouchFix());
          runCoverage = true;
        }
      }
    }

    builder.setFlags(toStringArray(flagArgs));
    builder.setFlagsParser(new IntelliJFlagParser(mySettings, dryRun));
    JsTestDriver jstd = builder.build();
    jstd.runConfiguration();
    if (runCoverage) {
      File[] coverageReportFiles = emptyOutputDir.listFiles(new FilenameFilter() {
        @Override
        public boolean accept(File dir, String name) {
View Full Code Here

      // load all the command line plugins.
      final List<Module> pluginModules = pluginLoader.load(cmdLinePlugins);
      logger.debug("loaded plugins %s", pluginModules);

      JsTestDriverBuilder builder = new JsTestDriverBuilder();
      BasePaths basePath = cmdLineFlags.getBasePath();
      builder.addBasePaths(basePath);
      builder.setDefaultConfiguration(new DefaultConfiguration(basePath));

      builder.setConfigurationSource(cmdLineFlags.getConfigurationSource());
      builder.addPluginModules(pluginModules);
      builder.withPluginInitializer(TestResultPrintingModule.TestResultPrintingInitializer.class);
      builder.setRunnerMode(cmdLineFlags.getRunnerMode());
      builder.setFlags(cmdLineFlags.getUnusedFlagsAsArgs());
      builder.addServerListener(new JstdIntellijServerListener());
      JsTestDriver jstd = builder.build();
      jstd.runConfiguration();

      logger.info("Finished action run.");
    } catch (InvalidFlagException e) {
      e.printErrorMessages(System.out);
View Full Code Here

 
      // load all the command line plugins.
      final List<Module> pluginModules = pluginLoader.load(cmdLinePlugins);
      logger.debug("loaded plugins %s", pluginModules);
 
      JsTestDriverBuilder builder = new JsTestDriverBuilder();
      builder.addBasePaths(cmdLineFlags.getBasePath());
      builder.setConfigurationSource(cmdLineFlags.getConfigurationSource());
      builder.addPluginModules(pluginModules);
      builder.withPluginInitializer(TestResultPrintingInitializer.class);
      builder.setRunnerMode(cmdLineFlags.getRunnerMode());
      builder.setFlags(cmdLineFlags.getUnusedFlagsAsArgs());
      JsTestDriver jstd = builder.build();
      jstd.runConfiguration();
 
      logger.info("Finished action run.");
    } catch (InvalidFlagException e) {
      e.printErrorMessages(System.out);
View Full Code Here

TOP

Related Classes of com.google.jstestdriver.embedded.JsTestDriverBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.