I would like to as for help which I have with performing tests while using the JBehave framework in Maven project. My story file looks like this:
Given new Messenger
When server is wp.pl
Then test connection is 0
When server is inf.ug.edu.pl and message is some_string
Then message send is 0
and class with tests looks like this:
import static org.junit.Assert.assertEquals;
import org.jbehave.core.annotations.Given;
import org.jbehave.core.annotations.Then;
import org.jbehave.core.annotations.When;
public class MessengerSteps {
private Messenger messenger;
@Given("new Messenger")
public void init() {
messenger = new Messenger(new MessageServiceClass());
}
@When("server is $server")
public void setServer(String server) {
messenger.setServer(server);
}
@When("server is $server and message is $message")
public void setServerAndMessage(String server, String message) {
System.out.println("Server: " + server + " Message: " + message);
messenger.setServer(server);
messenger.setMessage(message);
}
@Then("test connection is $number")
public void testConnection(int number) {
assertEquals(number, messenger.testConnection());
}
@Then("message send is $number")
public void sendMessage(int number) {
assertEquals(number, messenger.sendMessage());
}
}
First test which is checking the server string works correctly. However the second test which checks both the server and the message strings works incorrectly. For some reason a string "inf.ug.edu.pl and message is some_string" appears to be parsed to "server" variable in "setServerAndMessage" method instead of "inf.ug.edu.pl". It works correctly for integers and I remember it working correctly before I uploaded and cloned my project from a Git repository. I also give you the pom.xml file:
<project xmlns="http://ift.tt/IH78KX" xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/IH78KX http://ift.tt/VE5zRx">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.mockdemo</groupId>
<artifactId>messenger</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-core</artifactId>
<version>4.0-beta-11</version>
</dependency>
</dependencies>
I will be very grateful for help.
Aucun commentaire:
Enregistrer un commentaire