fhc*_*cat 7 java multithreading gradle gpars cucumber-jvm
我想在多个线程中运行相同的Cucumber测试.更具体地说,我有一组功能,在一个线程中运行这些功能可以正常工作.我使用JSON格式化程序来记录每个步骤的运行时间.现在我想做负载测试.我更关心多线程环境中每个功能/步骤的运行时间.所以我创建了多个线程,每个线程都运行在同一个功能集上.每个线程都有自己的JSON报告.理论上这可能吗?
对于某些项目设置原因,我无法使用JUnit运行程序.所以我不得不采用CLI方式:
long threadId = Thread.currentThread().getId();
String jsonFilename = String.format("json:run/cucumber%d.json", threadId);
String argv[] = new String[]{
"--glue",
"com.some.package",
"--format",
jsonFilename,
"d:\\features"};
// Do not call Main.run() directly. It has a System.exit() call at the end.
// Main.run(argv, Thread.currentThread().getContextClassLoader());
// Copied the same code from Main.run().
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
RuntimeOptions runtimeOptions = new RuntimeOptions(new Env("cucumber-jvm"), argv);
ResourceLoader resourceLoader = new MultiLoader(classLoader);
ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader);
Runtime runtime = new Runtime(resourceLoader, classFinder, classLoader, runtimeOptions);
runtime.writeStepdefsJson();
runtime.run();
Run Code Online (Sandbox Code Playgroud)
我试图为每个Cucumber运行创建一个单独的线程.问题是,只有一个线程有一个有效的JSON报告.所有其他线程只创建空JSON文件.这是黄瓜的设计还是我错过了什么?
| 归档时间: |
|
| 查看次数: |
2919 次 |
| 最近记录: |