Can you please put your project somewhere on github so it can be cloned
and debugged?
On 19/02/2013 19:15, Roy de Kleijn wrote:
I appreciate your help,
But there were no reports generated:
this is the output message [INFO] Generating reports view to
<projectname>' using formats '[]' and view properties
This is how the runner looks like:
public class RunWebStories extends JUnitStories {
private WebDriverProvider driverProvider = new
SeleniumWebDriverProvider();
private static final Logger LOG = Logger.getLogger(RunWebStories.class);
private Configuration configuration;
public RunWebStories() {
Embedder embedder = configuredEmbedder();
embedder.embedderControls().doGenerateViewAfterStories(true)
.doIgnoreFailureInStories(true).doIgnoreFailureInView(true)
.doVerboseFiltering(true);
//embedder.useExecutorService(MoreExecutors.sameThreadExecutor());
}
@Override
public Configuration configuration() {
configuration = makeConfiguration(this.getClass(),
driverProvider);
return configuration;
}
public static Configuration makeConfiguration(Class<?> embeddableClass,
WebDriverProvider driverProvider) {
Properties viewResources = new Properties();
viewResources.put("decorateNonHtml", "true");
ParameterConverters parameterConverters = new ParameterConverters();
ExamplesTableFactory examplesTableFactory = new ExamplesTableFactory(
new LocalizedKeywords(),
new LoadFromClasspath(embeddableClass), parameterConverters);
parameterConverters.addConverters(new DateConverter(
new SimpleDateFormat("yyyy-MM-dd")),
new ExamplesTableConverter(examplesTableFactory));
SeleniumConfiguration seleniumConfig = new SeleniumConfiguration();
seleniumConfig.useWebDriverProvider(driverProvider);
seleniumConfig.useStoryLoader(new
LoadFromClasspath(embeddableClass.getClassLoader()));
StoryReporterBuilder reporter = new StoryReporterBuilder();
reporter.withCodeLocation(
CodeLocations
.codeLocationFromClass(embeddableClass));
//.withDefaultFormats()
//.withFormats(new ScreenshootingHtmlFormat(driverProvider),
XML, CONSOLE, TXT);
reporter.withRelativeDirectory(
"jbehave/"
+ System.getProperty("conceptName")
+ "/"
+ System.getProperty("siteId")
);
seleniumConfig
.useFailureStrategy(new FailingUponPendingStep())
// .useStepMonitor(new SeleniumStepMonitor(contextView,
// seleniumContext, new SilentStepMonitor()))
.useStoryReporterBuilder(reporter)
.useParameterConverters(parameterConverters);// new
// SeleniumContextOutput(seleniumContext),
return seleniumConfig;
}
@Override
public InjectableStepsFactory stepsFactory() {
ApplicationContext context = new SpringApplicationContextFactory(
"org/spilgames/" + System.getProperty("conceptName")
+ "/config/config.xml").createApplicationContext();
return new SpringStepsFactory(configuration(), context);
}
@Override
protected List<String> storyPaths() {
return new StoryFinder().findPaths(
codeLocationFromClass(this.getClass()),
"**/" + System.getProperty("conceptName")
+ "/newStories/*.story", "**/excluded*.story");
}
}
and this is how the Spring Configuration looks like:
<bean id="screenshot" class="org.spilgames.ScreenshootingHtmlFormat">
<constructor-arg ref="provider" />
<constructor-arg value="SCREENSHOT" />
</bean>
<bean
class="org.jbehave.core.configuration.spring.SpringStoryReporterBuilder"
init-method="withDefaultFormats">
<property name="formats">
<list>
<ref bean="screenshot" />
<value>CONSOLE</value>
<value>TXT</value>
<value>XML</value>
</list>
</property>
</bean>
Any strange thing here ?
------------------------------------------------------------------------
*Van:* louis gueye [[email protected]]
*Verzonden:* dinsdag 19 februari 2013 18:21
*Aan:* [email protected]
*Onderwerp:* Re: [jbehave-user] Configure Custom reporter by Spring
config XML file
Hi Roy,
It should run out-of-the-box if your
org.spilgames.ScreenshootingHtmlFormat extends
org.jbehave.core.reporters.Format
Something like this should work.
class org.spilgames.ScreenshootingHtmlFormat extends
org.jbehave.core.reporters.Format {
private WebDriver driverProvider;
ScreenshootingHtmlFormat (WebDriver driverProvider, String name) {
super(name);
this.driverProvider = driverProvider;
}
}
<bean id="screenshot" class="org.spilgames.ScreenshootingHtmlFormat">
<constructor-arg ref="provider" />
<constructor-arg value="SCREENSHOT" />
</bean>
<bean
class="org.jbehave.core.configuration.spring.SpringStoryReporterBuilder"
init-method="withDefaultFormats">
<property name="formats">
<list>
<ref bean="screenshot"/>
<value>CONSOLE</value>
<value>TXT</value>
<value>XML</value>
</list>
</property>
</bean>
2013/2/19 Roy de Kleijn <[email protected]
<mailto:[email protected]>>
Thanks for your quick feedback ?
Where should I do that ? inside the spring configuration file ?
Can it also be done outside of spring config XML file ? and How
should that look like ?
In some way the tests are running again, but I still get an error
when a screenshot is made. driver = null
<bean id="screenshot" class="org.spilgames.ScreenshootingHtmlFormat">
<constructor-arg ref="provider" />
</bean>
<bean
class="org.jbehave.core.configuration.spring.SpringStoryReporterBuilder"
init-method="withDefaultFormats">
<property name="formats">
<list>
<ref bean="screenshot"/>
<value>CONSOLE</value>
<value>TXT</value>
<value>XML</value>
</list>
</property>
</bean>
This will let the test run, but gives me the driver = null error;
------------------------------------------------------------------------
*Van:* louis gueye [[email protected]
<mailto:[email protected]>]
*Verzonden:* dinsdag 19 februari 2013 14:12
*Aan:* [email protected] <mailto:[email protected]>
*Onderwerp:* Re: [jbehave-user] Configure Custom reporter by
Spring config XML file
Hi Roy,
Spring supports implicit conversion from string to Enum.
Other formats are Enum.
I guess you won't be able to inject non Enum value unless your
init-method (i.e withDefaultFormats) supports it.
I would pass a list of String as parameter to withDefaultFormat
method and then convert each string into the right formatter
instance then store it.
--
Cordialement/Regards,
Louis GUEYE
linkedin <http://fr.linkedin.com/in/louisgueye> | blog
<http://deepintojee.wordpress.com/> | twitter
<http://twitter.com/#%21/lgueye>
2013/2/19 Roy de Kleijn <[email protected]
<mailto:[email protected]>>
Hello,
I have the following question.
I implemented a custom reporter format
(http://jaroslav-sedlacek.blogspot.nl/2011/05/screenshots-in-jbehave-reports.html)
which creates a screenshot on failure and add a link to the
reports. Which works fine when using a single thread.
This is how I configured it in a class which extends from
JUnitStories:
StoryReporterBuilder reporter = new StoryReporterBuilder();
reporter.withCodeLocation(
CodeLocations
.codeLocationFromClass(embeddableClass))
.withFormats(new
ScreenshootingHtmlFormat(driverProvider), XML, CONSOLE, TXT);
This doesn't work when using multiple threads. Which seems to
be logical since the driverProvider is null.
So I added this custom reporter to the spring configuration
xml file. This is actually the place where I distribute the
driverProvider. I see that the screenshots are being made
(file are stored in a folder). However the HTML reports are
not generated properly.
So I tried to move the StoryReporterBuilder to the spring
configuration file is well: so it looks like this:
<bean id="screenshot"
class="org.spilgames.ScreenshootingHtmlFormat">
<constructor-arg ref="provider" />
</bean>
<bean
class="org.jbehave.core.configuration.spring.SpringStoryReporterBuilder"
init-method="withDefaultFormats">
<property name="formats">
<list>
<value>CONSOLE</value>
<value>TXT</value>
<value>screenshot</value>
<value>XML</value>
</list>
</property>
</bean>
However this doesn't work for customformats. Is there a
workaround? or is there another to do this ? How can I define
the custom format in the Spring Configuration XML file?
The first bean in the above example is working (screenshots
are being made)
The second bean needs some modification, because it gets stuck
at the third parameter.
Any help is appreciated!
Thanks,
Roy
--
Cordialement/Regards,
Louis GUEYE
linkedin <http://fr.linkedin.com/in/louisgueye> | blog
<http://deepintojee.wordpress.com/> | twitter
<http://twitter.com/#%21/lgueye>