Friday, 30 November 2012
Wednesday, 14 November 2012
BDD with NBehave starter example
Here is a quick help for BDD with NBehave beginners.
Also refer to this presentation by me on BDD and UADD at the Agile NCR conference - BDD and UADD with Slim
The .feature text file that describes the scenario(s) and which gets executed by NBehave !
The ActionSteps that define the actions proposed in the .feature file above in the BDD format of Given, When, Then.
And the production class,
public class Calculator
{
private int result;
private int one, two;
public void Enter(int o,int t)
{
one = o;
two = t;
}
public void Add()
{
result = one + two;
}
public int Value() {
return result;
}
}
Below is the nbehave results
Labels:
BDD,
Jv,
Jv Ravichandran,
NBehave,
nunit,
Ravichandran J.V.,
Unit Testing scenarios
Monday, 12 November 2012
Behavior Driven Development with Tumbler
Will elaborate on comments and questions to this post :)
More on this can be found at - http://ravichandranjv.blogspot.in/2010/05/decision-table-in-slim.html
Also refer to this presentation by me on BDD and UADD at the Agile NCR conference - http://tinyurl.com/d6xjfox
import static tumbler.Tumbler.*;
import org.junit.runner.Result;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
import tumbler.Scenario;
import tumbler.Story;
import org.hamcrest.BaseMatcher;
import org.hamcrest.core.IsEqual;
import org.hamcrest.core.IsNot;
import org.hamcrest.core.IsNull;
import org.hamcrest.core.IsSame;
import tumbler.JUnit44TumblerRunner;
import tumbler.TumblerRunner;
@RunWith(JUnit44TumblerRunner.class)
@Story("Generate genome sequence from values passed")
public class GenomeTest {
@Scenario("ATGAC")
public void shouldGenerateCorrectPatern() {
Given("A Genome sequence");
GenomePattern gp = new GenomePattern();
Object someValue=null;
When("Genome pattern is to be generated");
Result result = gp.generatePattern();
Then("expect ATGAC");
assertNull(result); // Making test pass as per TDD
}
}
More on this can be found at - http://ravichandranjv.blogspot.in/2010/05/decision-table-in-slim.html
Also refer to this presentation by me on BDD and UADD at the Agile NCR conference - http://tinyurl.com/d6xjfox
import static tumbler.Tumbler.*;
import org.junit.runner.Result;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
import tumbler.Scenario;
import tumbler.Story;
import org.hamcrest.BaseMatcher;
import org.hamcrest.core.IsEqual;
import org.hamcrest.core.IsNot;
import org.hamcrest.core.IsNull;
import org.hamcrest.core.IsSame;
import tumbler.JUnit44TumblerRunner;
import tumbler.TumblerRunner;
@RunWith(JUnit44TumblerRunner.class)
@Story("Generate genome sequence from values passed")
public class GenomeTest {
@Scenario("ATGAC")
public void shouldGenerateCorrectPatern() {
Given("A Genome sequence");
GenomePattern gp = new GenomePattern();
Object someValue=null;
When("Genome pattern is to be generated");
Result result = gp.generatePattern();
Then("expect ATGAC");
assertNull(result); // Making test pass as per TDD
}
}
Subscribe to:
Posts (Atom)