当前位置: 首页>>代码示例>>Java>>正文


Java CucumberException类代码示例

本文整理汇总了Java中cucumber.runtime.CucumberException的典型用法代码示例。如果您正苦于以下问题:Java CucumberException类的具体用法?Java CucumberException怎么用?Java CucumberException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CucumberException类属于cucumber.runtime包,在下文中一共展示了CucumberException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getOutputFile

import cucumber.runtime.CucumberException; //导入依赖的package包/类
public File getOutputFile(Class testClass) {
	if(testClass == null) {
		throw new IllegalArgumentException("testClass cannot be null");
	}

	try {
		File outputFolder = new File(Constants.RESULTS_FOLDER);
		Files.createDirectories(outputFolder.toPath()); // if directory already exists will do nothing

		//testClass.getName() is the unique identifier of the class
		String fileName = String.format("%s_%s", testClass.getName(), Constants.RESULTS_FILE_NAME_POSTFIX);
		File outputFile = new File(outputFolder, fileName);
		outputFile.createNewFile(); // if file already exists will do nothing
		return outputFile;
	} catch (IOException e) {
		throw new CucumberException(Constants.errorPrefix + "Failed to create cucumber results output directory", e);
	}
}
 
开发者ID:MicroFocus,项目名称:octane-cucumber-jvm,代码行数:19,代码来源:OutputFile.java

示例2: getResourceLoader

import cucumber.runtime.CucumberException; //导入依赖的package包/类
private ResourceLoader getResourceLoader() {
	List<Path> fileSystemFeaturePaths = getFileSystemFeaturePaths();
	if (fileSystemFeaturePaths.size() == 0)
		return new MultiLoader(cucumberClassLoader);
	URL[] urls = new URL[fileSystemFeaturePaths.size()];
	int index = 0;
	for (Path featurePath : fileSystemFeaturePaths) {
		try {
			urls[index] = featurePath.toUri().toURL();
		} catch (MalformedURLException e) {
			throw new CucumberException(e);
		}
		index++;
	}
	URLClassLoader featuresLoader = new URLClassLoader(urls, cucumberClassLoader);
	return new MultiLoader(featuresLoader);
}
 
开发者ID:djb61,项目名称:parallel-cucumber-jvm,代码行数:18,代码来源:CucumberRuntimeFactory.java

示例3: run

import cucumber.runtime.CucumberException; //导入依赖的package包/类
public byte run() throws InterruptedException, IOException {
	byte result = 0;
	ExecutorService executor = Executors.newFixedThreadPool(rerunFiles.size());
	List<CucumberRuntimeCallable> runtimes = new ArrayList<CucumberRuntimeCallable>();
	for (Path rerunFile : rerunFiles) {
		CucumberRuntimeCallable runtimeCallable = new CucumberRuntimeCallable(buildCallableRuntimeArgs(rerunFile),
				runtimeFactory);
		runtimes.add(runtimeCallable);
	}
	List<Future<Byte>> futures = executor.invokeAll(runtimes);
	executor.shutdown();
	for (Future<Byte> future : futures)
		try {
			byte callableResult = future.get();
			result |= callableResult;
		} catch (ExecutionException e) {
			if (e.getCause() instanceof CucumberException)
				throw (CucumberException) e.getCause();
			else
				throw new CucumberException(e.getCause());
		}
	return result;
}
 
开发者ID:djb61,项目名称:parallel-cucumber-jvm,代码行数:24,代码来源:CucumberRuntimeExecutor.java

示例4: buildFeatureElementRunners

import cucumber.runtime.CucumberException; //导入依赖的package包/类
private void buildFeatureElementRunners() {
   for (CucumberTagStatement cucumberTagStatement : cucumberFeature
      .getFeatureElements()) {
      try {
         ParentRunner<?> featureElementRunner;
         if (cucumberTagStatement instanceof CucumberScenario) {
            featureElementRunner =
               new RestExecutionUnitRunner(runtime, cucumberTagStatement,
                  jUnitReporter, cucumberFeature);
         } else {
            featureElementRunner =
               new RestScenarioOutlineRunner(runtime,
                  (CucumberScenarioOutline) cucumberTagStatement, jUnitReporter,
                  cucumberFeature);
         }
         children.add(featureElementRunner);
      } catch (InitializationError e) {
         throw new CucumberException("Failed to create scenario runner", e);
      }
   }
}
 
开发者ID:LiamHayes1,项目名称:rest-cucumber,代码行数:22,代码来源:RestFeatureRunner.java

示例5: CucumberReporter

import cucumber.runtime.CucumberException; //导入依赖的package包/类
/**
 * Constructor of cucumberReporter.
 *
 * @param url url
 * @param cClass class
 * @throws IOException exception
 */
public CucumberReporter(String url, String cClass, String additional) throws IOException {
    this.url = url;
    this.cClass = cClass;
    this.additional = additional;

    try {
        document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
        results = document.createElement("testng-results");
        suite = document.createElement("suite");
        test = document.createElement("test");
        callerClass = cClass;
        suite.appendChild(test);
        results.appendChild(suite);
        document.appendChild(results);
        jUnitDocument = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
        jUnitResults = jUnitDocument.createElement("testsuites");
        jUnitSuite = jUnitDocument.createElement("testsuite");
        jUnitDocument.appendChild(jUnitResults);
        jUnitResults.appendChild(jUnitSuite);
    } catch (ParserConfigurationException e) {
        throw new CucumberException("Error initializing DocumentBuilder.", e);
    }
}
 
开发者ID:Stratio,项目名称:bdt,代码行数:31,代码来源:CucumberReporter.java

示例6: runCukes

import cucumber.runtime.CucumberException; //导入依赖的package包/类
/**
 * Run the testclases(Features).
 *
 * @throws IOException exception
 * @throws NoSuchMethodException exception
 * @throws InvocationTargetException exception
 * @throws IllegalAccessException exception
 */
public void runCukes() throws IOException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {

    runtime.run();

    if (!runtime.getErrors().isEmpty()) {
        Iterator<Throwable> iterator = runtime.getErrors().iterator();
        while (iterator.hasNext()) {
            Throwable value = iterator.next();
            if (value.getMessage().contains("TESTS EXECUTION ABORTED!")) {
                iterator.remove();
            }
        }
        logger.error ("Got {} exceptions", runtime.getErrors());
        throw new CucumberException(runtime.getErrors().get(0));
    }
}
 
开发者ID:Stratio,项目名称:bdt,代码行数:25,代码来源:CucumberRunner.java

示例7: execute

import cucumber.runtime.CucumberException; //导入依赖的package包/类
@Override
public void execute(Scenario scenario) throws Throwable {
    Object[] args;
    switch (method.getParameterTypes().length) {
        case 0:
            args = new Object[0];
            break;
        case 1:
            if (!Scenario.class.equals(method.getParameterTypes()[0])) {
                throw new CucumberException("When a hook declares an argument it must be of type " + Scenario.class.getName() + ". " + method.toString());
            }
            args = new Object[]{scenario};
            break;
        default:
            throw new CucumberException("Hooks must declare 0 or 1 arguments. " + method.toString());
    }

    Utils.invoke(objectFactory.getInstance(method.getDeclaringClass()), method, timeout, args);
}
 
开发者ID:mfellner,项目名称:cucumber-android,代码行数:20,代码来源:JavaHookDefinition.java

示例8: scan

import cucumber.runtime.CucumberException; //导入依赖的package包/类
/**
 * Registers step definitions and hooks.
 *
 * @param androidBackend the backend where stepdefs and hooks will be registered.
 * @param method         a candidate for being a stepdef or hook.
 * @param glueCodeClass  the class where the method is declared.
 */
void scan(AndroidBackend androidBackend, Method method, Class<?> glueCodeClass) {
    for (Class<? extends Annotation> cucumberAnnotationClass : mCucumberAnnotationClasses) {
        Annotation annotation = method.getAnnotation(cucumberAnnotationClass);
        if (annotation != null) {
            if (!method.getDeclaringClass().isAssignableFrom(glueCodeClass)) {
                throw new CucumberException(String.format("%s isn't assignable from %s", method.getDeclaringClass(), glueCodeClass));
            }
            if (!glueCodeClass.equals(method.getDeclaringClass())) {
                throw new CucumberException(String.format("You're not allowed to extend classes that define Step Definitions or hooks. %s extends %s", glueCodeClass, method.getDeclaringClass()));
            }
            if (isHookAnnotation(annotation)) {
                androidBackend.addHook(annotation, method);
            } else if (isStepdefAnnotation(annotation)) {
                androidBackend.addStepDefinition(annotation, method);
            }
        }
    }
}
 
开发者ID:mfellner,项目名称:cucumber-android,代码行数:26,代码来源:AndroidClasspathMethodScanner.java

示例9: extractStep

import cucumber.runtime.CucumberException; //导入依赖的package包/类
protected Step extractStep(final StepDefinitionMatch match) {
    try {
        final Field step = match.getClass().getDeclaredField("step");
        step.setAccessible(true);
        return (Step) step.get(match);
    } catch (ReflectiveOperationException e) {
        //shouldn't ever happen
        LOG.error(e.getMessage(), e);
        throw new CucumberException(e);
    }
}
 
开发者ID:allure-framework,项目名称:allure-java,代码行数:12,代码来源:StepUtils.java

示例10: KarateJunitFormatter

import cucumber.runtime.CucumberException; //导入依赖的package包/类
public KarateJunitFormatter(String featurePath, String reportPath) throws IOException {
    this.featurePath = featurePath;
    this.reportPath = reportPath;
    logger.trace(">> {}", reportPath);
    URL url = FileUtils.toFileUrl(reportPath);
    this.out = new UTF8OutputStreamWriter(new URLOutputStream(url));
    try {
        doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
        rootElement = doc.createElement("testsuite");
        doc.appendChild(rootElement);
    } catch (ParserConfigurationException e) {
        throw new CucumberException("Error while processing unit report", e);
    }
}
 
开发者ID:intuit,项目名称:karate,代码行数:15,代码来源:KarateJunitFormatter.java

示例11: done

import cucumber.runtime.CucumberException; //导入依赖的package包/类
@Override
public void done() {
    try {
        String featureName = StringUtils.trimToNull(testCase.feature.getName());
        if (featureName == null) {
            featureName = featurePath;
        }
        rootElement.setAttribute("name", featureName);
        testCount = Integer.valueOf(rootElement.getAttribute("tests"));
        failCount = rootElement.getElementsByTagName("failure").getLength();
        rootElement.setAttribute("failures", String.valueOf(failCount));
        skipCount = rootElement.getElementsByTagName("skipped").getLength();
        rootElement.setAttribute("skipped", String.valueOf(skipCount));
        timeTaken = sumTimes(rootElement.getElementsByTagName("testcase"));
        rootElement.setAttribute("time", formatTime(timeTaken));
        printStatsToConsole();
        if (rootElement.getElementsByTagName("testcase").getLength() == 0) {
            addDummyTestCase(); // to avoid failed Jenkins jobs
        }
        TransformerFactory transfac = TransformerFactory.newInstance();
        Transformer trans = transfac.newTransformer();
        trans.setOutputProperty(OutputKeys.INDENT, "yes");
        StreamResult result = new StreamResult(out);
        DOMSource source = new DOMSource(doc);
        trans.transform(source, result);
    } catch (TransformerException e) {
        throw new CucumberException("Error while transforming.", e);
    }
    logger.trace("<< {}", reportPath);
}
 
开发者ID:intuit,项目名称:karate,代码行数:31,代码来源:KarateJunitFormatter.java

示例12: HPEAlmOctaneGherkinFormatter

import cucumber.runtime.CucumberException; //导入依赖的package包/类
public HPEAlmOctaneGherkinFormatter(ResourceLoader resourceLoader, List<String> features, OutputFile outputFile) {
    cucumberFeatures = features;
    cucumberResourceLoader = resourceLoader;
    this.outputFile = outputFile;
    try {
        _doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
        _rootElement = _doc.createElement(GherkinSerializer.ROOT_TAG_NAME);
        _rootElement.setAttribute("version",Constants.XML_VERSION);
        _doc.appendChild(_rootElement);
    } catch (ParserConfigurationException e) {
        throw new CucumberException(Constants.errorPrefix + "Failed to create xml document",e);
    }
}
 
开发者ID:MicroFocus,项目名称:octane-cucumber-jvm,代码行数:14,代码来源:HPEAlmOctaneGherkinFormatter.java

示例13: addFeatureFileInfo

import cucumber.runtime.CucumberException; //导入依赖的package包/类
private void addFeatureFileInfo(String featureFile) {
    try {
        Resource resource = findResource(featureFile);
        FeatureBuilder builder = new FeatureBuilder(new ArrayList<CucumberFeature>());
        _currentFeature.setPath(((FileResource) resource).getFile().getPath());
        _currentFeature.setFile(builder.read(resource));
    } catch (Exception e) {
        throw new CucumberException(Constants.errorPrefix + "Failed to find feature file:" + featureFile ,e);
    }
}
 
开发者ID:MicroFocus,项目名称:octane-cucumber-jvm,代码行数:11,代码来源:HPEAlmOctaneGherkinFormatter.java

示例14: write

import cucumber.runtime.CucumberException; //导入依赖的package包/类
public void write(Document doc) {
	File file = getOutputFile(testClass);
	try (FileOutputStream outputStream = new FileOutputStream(file)) {
		DOMImplementationRegistry reg = DOMImplementationRegistry.newInstance();
		DOMImplementationLS impl = (DOMImplementationLS) reg.getDOMImplementation("LS");
		LSSerializer serializer = impl.createLSSerializer();
		LSOutput output = impl.createLSOutput();
		output.setByteStream(outputStream);
		serializer.write(doc, output);
	} catch (Exception e) {
		throw new CucumberException(Constants.errorPrefix + "Failed to write document to disc", e);
	}
}
 
开发者ID:MicroFocus,项目名称:octane-cucumber-jvm,代码行数:14,代码来源:OutputFile.java

示例15: tearDown

import cucumber.runtime.CucumberException; //导入依赖的package包/类
@Override
public void tearDown() {
    try {
        getAppiumDriver().runAppInBackground(2);
    }
    catch (Exception e) {
        throw new CucumberException("Failed to collect code coverage data!", e);
    }
}
 
开发者ID:HotwireDotCom,项目名称:bdd-test-automation-for-mobile,代码行数:10,代码来源:IosApplication.java


注:本文中的cucumber.runtime.CucumberException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。