Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JBehave Junit Runner引发NullPointerException_Java_Eclipse_Junit_Jbehave_Jbehave Plugin - Fatal编程技术网

Java JBehave Junit Runner引发NullPointerException

Java JBehave Junit Runner引发NullPointerException,java,eclipse,junit,jbehave,jbehave-plugin,Java,Eclipse,Junit,Jbehave,Jbehave Plugin,我是JBehave新手,正在尝试使用JBehave JUnit Runner在EclipseLuna(在Ubuntu12.04上)的JUnit中很好地显示测试结果。我使用的是JBehave JUnit Runner 1.1.2、JUnit 4.12-beta-1和JBehave core 4.0-beta-9。当我右键单击我的故事文件并“作为JUnit测试运行”时,一切都很好。但是,当我按照JBehave JUnit Runner的要求将@RunWith(JUnitReportingRunner

我是JBehave新手,正在尝试使用JBehave JUnit Runner在EclipseLuna(在Ubuntu12.04上)的JUnit中很好地显示测试结果。我使用的是JBehave JUnit Runner 1.1.2、JUnit 4.12-beta-1和JBehave core 4.0-beta-9。当我右键单击我的故事文件并“作为JUnit测试运行”时,一切都很好。但是,当我按照JBehave JUnit Runner的要求将@RunWith(JUnitReportingRunner.class)放在故事类的顶部时,我得到了以下错误:

java.lang.RuntimeException: java.lang.NullPointerException
at de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner.run(JUnitReportingRunner.java:80)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.NullPointerException
at de.codecentric.jbehave.junit.monitoring.JUnitScenarioReporter.afterStory(JUnitScenarioReporter.java:114)
at org.jbehave.core.reporters.DelegatingStoryReporter.afterStory(DelegatingStoryReporter.java:49)
at org.jbehave.core.reporters.ConcurrentStoryReporter.afterStory(ConcurrentStoryReporter.java:120)
at org.jbehave.core.embedder.PerformableTree.performBeforeOrAfterStories(PerformableTree.java:399)
at org.jbehave.core.embedder.StoryManager.performStories(StoryManager.java:102)
at org.jbehave.core.embedder.StoryManager.runStories(StoryManager.java:93)
at org.jbehave.core.embedder.StoryManager.runStoriesAsPaths(StoryManager.java:74)
at org.jbehave.core.embedder.Embedder.runStoriesAsPaths(Embedder.java:204)
at de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner.run(JUnitReportingRunner.java:78)
... 6 more
这是我用于测试的实用程序类。一种非常基本的方法:

package org.felimar;

public abstract class StringManipulation
{
  public static boolean stringBlank(final String src)
  {
    return src.matches("^\\s*$"); //$NON-NLS-1$
  }
}
JBehave的故事文件:

Utilities for managing character strings

Narrative:
In order to easily manipulate and investigate character strings
As a development team
I want to use a group of string-related utilities

Scenario:  A string contains zero or more characters
Given a source string with value <value>
Then the method should return <return>

Examples:
|value|return|
|""|true|
|" "|true|
|"Normal Non-Blank"|false|
最后,故事课:

package org.felimar.stories;

import static java.util.Arrays.asList;
import static org.jbehave.core.reporters.Format.CONSOLE;
import static org.jbehave.core.reporters.Format.TXT;

import java.util.List;

import org.felimar.StringManipulation;
import org.felimar.steps.StringManipulationSteps;
import org.jbehave.core.configuration.MostUsefulConfiguration;
import org.jbehave.core.junit.JUnitStories;
import org.jbehave.core.reporters.StoryReporterBuilder;
import org.jbehave.core.steps.InjectableStepsFactory;
import org.jbehave.core.steps.InstanceStepsFactory;
import org.junit.runner.RunWith;

import de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner;

@RunWith(JUnitReportingRunner.class)
public class StringManipulationStories extends JUnitStories
{
  public StringManipulationStories()
  {
    super();
    super.useConfiguration(
     new MostUsefulConfiguration().useStoryReporterBuilder(
      new StoryReporterBuilder().withDefaultFormats().withFormats(
          CONSOLE, TXT)));
  }

  @Override
  public InjectableStepsFactory stepsFactory()
  {
    return new InstanceStepsFactory(configuration(),
                                   new StringManipulationSteps());
  }

  @Override
  protected List<String> storyPaths()
  {
    return asList("org/felimar/stories/StringManipulationStories.story");
  }
}
package org.felimar.stories;
导入静态java.util.Arrays.asList;
导入静态org.jbehave.core.reporters.Format.CONSOLE;
导入静态org.jbehave.core.reporters.Format.TXT;
导入java.util.List;
导入org.felimar.StringManipulation;
导入org.felimar.steps.StringOperationSteps;
导入org.jbehave.core.configuration.mostuseveConfiguration;
导入org.jbehave.core.junit.JUnitStories;
导入org.jbehave.core.reporters.StoryReporterBuilder;
导入org.jbehave.core.steps.InjectableStepsFactory;
导入org.jbehave.core.steps.InstanceStepsFactory;
导入org.junit.runner.RunWith;
导入de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner;
@RunWith(JUnitReportingRunner.class)
公共类StringManufactionStories扩展了JUnitStories
{
公共机构
{
超级();
超级用户配置(
新建MOSTUSIVEConfiguration().useStoryReporterBuilder(
新建StoryReporterBuilder().withDefaultFormats().withFormats(
控制台(TXT));
}
@凌驾
公共可注射步骤工厂步骤工厂()
{
返回新InstanceStepsFactory(配置(),
新的StringOperationSteps());
}
@凌驾
受保护的列表故事路径()
{
返回asList(“org/felimar/stories/stringmanufactionstories.story”);
}
}

代码中是否有任何明显的错误,或者我是否应该停止使用测试库?

我发现问题出在JUnit-4.12-beta-1上。我将Gradle构建脚本设置为4.+,因此我将其更改为指定为4.11,问题就消失了。JBehave core 4.0-beta-9似乎工作得很好,所以我将其保留了下来

我还尝试使用JUnitReportingRunner.RecommantedControls(configuredEmbedder());作为构造函数的最后一行,但它实际上抛出了一个额外的错误

我感谢安德烈亚斯提出的有益建议,他们非常感谢,并最终帮助我解决了问题

亲切问候,,
我发现问题出在JUnit-4.12-beta-1上。我将Gradle构建脚本设置为4.+,因此我将其更改为指定为4.11,问题就消失了。JBehave core 4.0-beta-9似乎工作得很好,所以我将其保留了下来

我还尝试使用JUnitReportingRunner.RecommantedControls(configuredEmbedder());作为构造函数的最后一行,但它实际上抛出了一个额外的错误

我感谢安德烈亚斯提出的有益建议,他们非常感谢,并最终帮助我解决了问题

亲切问候,,
我发现问题出在JUnit-4.12-beta-1上。我将Gradle构建脚本设置为4.+,因此我将其更改为指定为4.11,问题就消失了。JBehave core 4.0-beta-9似乎工作得很好,所以我将其保留了下来

我还尝试使用JUnitReportingRunner.RecommantedControls(configuredEmbedder());作为构造函数的最后一行,但它实际上抛出了一个额外的错误

我感谢安德烈亚斯提出的有益建议,他们非常感谢,并最终帮助我解决了问题

亲切问候,,
我发现问题出在JUnit-4.12-beta-1上。我将Gradle构建脚本设置为4.+,因此我将其更改为指定为4.11,问题就消失了。JBehave core 4.0-beta-9似乎工作得很好,所以我将其保留了下来

我还尝试使用JUnitReportingRunner.RecommantedControls(configuredEmbedder());作为构造函数的最后一行,但它实际上抛出了一个额外的错误

我感谢安德烈亚斯提出的有益建议,他们非常感谢,并最终帮助我解决了问题

亲切问候,,
Flic

乍一看,代码看起来很好。我自己还没有在4.0测试版上试用过。同一示例是否适用于JBehave的稳定版本?如果是,我想请您在github上的跟踪器中为此创建一个问题:您可以尝试使用JUnitReportingRunner.RecommantedControls(configuredEmbedder());在您的构造函数中作为最后一行,如下所述:感谢您的建议Andreas。我回答了我的问题,解释了你的哪些建议对我有效,并根据你的要求在GitHub(#70)上提出了一个问题。乍一看,代码看起来很好。我自己还没有在4.0测试版上试用过。同一示例是否适用于JBehave的稳定版本?如果是,我想请您在github上的跟踪器中为此创建一个问题:您可以尝试使用JUnitReportingRunner.RecommantedControls(configuredEmbedder());在您的构造函数中作为最后一行,如下所述:感谢您的建议Andreas。我回答了我的问题,解释了你的哪些建议对我有效,并根据你的要求在GitHub(#70)上提出了一个问题。乍一看,代码看起来很好。我自己还没有在4.0测试版上试用过。同一示例是否适用于JBehave的稳定版本?如果是,我想请您在github上的跟踪器中为此创建一个问题:您可以尝试使用JUnitReportingRunner.RecommantedControls(configuredEmbedder());在您的构造函数中作为最后一行,如下所述:感谢您的建议Andreas。
package org.felimar.stories;

import static java.util.Arrays.asList;
import static org.jbehave.core.reporters.Format.CONSOLE;
import static org.jbehave.core.reporters.Format.TXT;

import java.util.List;

import org.felimar.StringManipulation;
import org.felimar.steps.StringManipulationSteps;
import org.jbehave.core.configuration.MostUsefulConfiguration;
import org.jbehave.core.junit.JUnitStories;
import org.jbehave.core.reporters.StoryReporterBuilder;
import org.jbehave.core.steps.InjectableStepsFactory;
import org.jbehave.core.steps.InstanceStepsFactory;
import org.junit.runner.RunWith;

import de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner;

@RunWith(JUnitReportingRunner.class)
public class StringManipulationStories extends JUnitStories
{
  public StringManipulationStories()
  {
    super();
    super.useConfiguration(
     new MostUsefulConfiguration().useStoryReporterBuilder(
      new StoryReporterBuilder().withDefaultFormats().withFormats(
          CONSOLE, TXT)));
  }

  @Override
  public InjectableStepsFactory stepsFactory()
  {
    return new InstanceStepsFactory(configuration(),
                                   new StringManipulationSteps());
  }

  @Override
  protected List<String> storyPaths()
  {
    return asList("org/felimar/stories/StringManipulationStories.story");
  }
}