JBehave를 처음 사용하고 JBehave-JUnit-Runner를 사용하여 Eclipse Luna (Ubuntu 12.04)의 JUnit에서 테스트 결과를 멋지게 표시하려고합니다. JBehave-JUnit-Runner 1.1.2, JUnit 4.12-beta-1 및 JBehave-core 4.0-beta-9를 사용하고 있습니다. 내 이야기 파일을 마우스 오른쪽 버튼으로 클릭하고 'Run as JUnit Test'를 클릭하면 모두 잘됩니다. JBehave의-의 JUnit 러너에 필요한 내 이야기 클래스의 상단에있는 @RunWith (JUnitReportingRunner.class)를 넣을 때, 나는 다음과 같은 오류가 발생합니다 :JBehave-Junit-Runner throw NullPointerException
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.steps;
import static org.felimar.StringManipulation.stringBlank;
import org.felimar.StringManipulation;
import org.jbehave.core.annotations.Given;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
public class StringManipulationSteps
{
private String m_srcString;
public String getSrcString()
{
return m_srcString;
}
@Given("a source string with value $value")
public void givenValue(@Named("value") final String srcString)
{
setSrcString(srcString);
}
public void setSrcString(final String srcString)
{
m_srcString = srcString;
}
@Then("the method should return $value")
public void stringBlankRtrns(@Named("value") final boolean isBlank)
{
if (stringBlank(getSrcString()) != isBlank)
throw new RuntimeException("stringBlank did not determine *" +
getSrcString() + "* was " + isBlank);
}
}
그리고 마지막으로, 이야기 클래스 :
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");
}
}
t에 명백한 오류가 있습니까? 그가 코딩했거나 베타 라이브러리 사용을 중단해야합니까?
는 코드가 잘 보인다. 아직 4.0 베타 버전에서 직접 시도하지 않았습니다. 동일한 예제가 JBehave의 안정적인 버전에서 작동합니까? 그렇다면 gittub의 Google 추적 프로그램에서 문제를 만들도록 요청하겠습니다. https://github.com/codecentric/jbehave-junit-runner/issues – AndreasEK
시도해 볼 수있는 한 가지는 입니다. JUnitReportingRunner.recommandedControls (configuredEmbedder()); 마지막 줄로 작성자 : https://github.com/codecentric/jbehave-junit-runner#enabling – AndreasEK
제안 해 주신 Andreas에게 감사드립니다. 나는 내 질문에 대답하여 내게 도움이 된 제안을 설명하고 GitHub (# 70)에서 문제를 제기했다. – Flic