title: How do I Combine BDD and TDD in a MVC Project?
body: <p>We are trying to combine BDD and TDD approach in our new project. </p>
  
  <p>Using Specflow, NUnit and WatiN in our MVC3 project, I'm trying to follow the logic of Outside-in process. <a href="http://msdn.microsoft.com/en-us/magazine/gg490346.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/magazine/gg490346.aspx</a>
  I would like to know what I’m trying to do is correct.</p>
  
  <pre><code>Feature: Commit RPI, As any user, I want to commit all RPI values
  
  Scenario: Commit RPI values, Given I am in the RPI screen And I have entered RPI values
  
  | Year | Month | RPI Value |    
  | 2012 | 1     | 1.2       |
  </code></pre>
  
  <p>When I want to commit RPI values, then RPI values should be committed</p>
  
  <p>Acceptance tests will be as below:</p>
  
  <pre><code>[Given(@"I am in the RPI screen")]    
  public void GivenIAmInTheRPIScreen()    
  {    
      WebBrowser.Current.GoTo("http://localhost:8010/");    //WebBrowser is the instance of Internet Explorer created by WatiN
      Assert.AreEqual(WebBrowser.Current.Title, "RPI List");
  }
  
  ***This step will initially fail as there will not be any RPI List screen. So, I’ll go to the web project, create a controller and view. When I run the test again, WatiN will be able to open up the screen and pass the test.***
  
  [Given(@"I have entered RPI values")]    
  public void GivenIHaveEnteredRPIValues(Table tblRPI)
  {    
      if (tblRPI.Rows.Count &gt; 0)   
      {
          var txtYear = (TextField) WebBrowser.Current.Elements.First(Find.ById("txtRPIYear"));
  
          if (txtYear != null) 
             txtYear.Value = tblRPI.Rows[0]["Year"];
  
          var txtMonth = (TextField)WebBrowser.Current.Elements.First(Find.ById("txtRPIMonth"));
  
          if (txtMonth != null)
              txtMonth.Value = tblRPI.Rows[0]["Month"];
  
          var txtValue = (TextField)WebBrowser.Current.Elements.First(Find.ById("txtRPIValue"));
  
          if (txtValue != null)
              txtValue.Value = tblRPI.Rows[0]["RPI Value"];
      }
      else    
      {
          Assert.True(false);
      }
  }
  
  [When(@"I want to commit RPI values")]    
  public void WhenIWantToCommitRPIValues()
  {
  
     var btnCommitValues = (Button)WebBrowser.Current.Elements.First(Find.ById("btnCommitValues"));
  
     if (btnCommitValues != null)
     {
         btnCommitValues.Focus();
     }
     else
     {
         Assert.IsTrue(btnCommitValues != null);
     }
  }
  
  [Then(@"RPI values should be committed")]
  public void ThenRPIValuesShouldBeCommitted()
  {
      var btnCommitValues = (Button)WebBrowser.Current.Elements.First(Find.ById("btnCommitValues"));
  
      if (btnCommitValues != null)
      {
          btnCommitValues.Click();
      }
      else
      {
          Assert.IsTrue(btnCommitValues != null);    
      }
  }
  </code></pre>
  
  <p><strong><em>This step will fail as there will not be any logic to commit the values. At this stage, I will stop BDD and go ahead to write my unit test cases for the commit logic. I will write various test cases using NUnit, make them pass so that when I come back to the acceptanace test, there will be a logic to commit RPI values which would have passed my unit tests and the acceptance test will now pass.</em></strong></p>
  
  <p>My question is almost similar to this <a href="https://stackoverflow.com/questions/7013734/how-do-specflow-features-link-to-unit-tests-in-asp-net-webforms-projects">How do specflow features link to unit tests in asp.net webforms projects?</a></p>
  
  <p>If you have done similar work using SpecFlow, NUnit and MVC, could you please share your thoughts. .</p>