ok, for now I will kill the process before starting the server, until
the issue gets fixed.
As for your question...
In my team we are using SpecFlow in a small project we started working
on.
We are using an IoC Container (Castle) to not only resolve components
for the application through configuration, but also to instantiate
acceptance test-specific components (the steps and other things),
depending on the type of test we're running.
So, for instance, if we execute the nant build script to run
Controller-level tests, certain properties are set so the Controller-
test steps implementations are registered in the container.
On the other hand, if we decide to test using WatiN, we run the nant
script to set properties and register components for browser specific
tests: WatiN browser, (which can either be IE or Firefox if we wish),
the server (we're using the local .Net WebDev.WebServer.exe, which we
wrap in a class that starts it using a System.Diagnostics.Process
object, and the browser steps implementations.
In terms of how the projects are structured, this is how we did it:
* Acceptance.Features.csproj
-- Global.cs (contains hooks such as BeforeTestRun, BeforeScenario
etc.)
The code within each hook simply calls the corresponding method in
the ITestFixtureSetup interface. The implementation of this interface
depends on whether we're running Controller level tests
(ControllerTestFixtureSetup.cs) or UI tests
(WatiNTestFixtureSetup.cs ..... here is where WatiN browser gets
instantiated and disposed and where the web server is started and
stopped).
-- One folder per each concept of the app. Eg: UserAccount, which will
contain all the .feature files for the UserAccount, such as
LogIn.feature, CreateAccount.feature, etc.
-- tests.properties file which has some general properties and the
type of ITestFixtureSetup implementation to use. This file is modified
at compile time by a nant script, to set the correct implementation of
the fixture setup to be used, among other acceptance test-specific
properties.
* Acceptance.Steps.csproj
-- in here we have one step file for each of the concerns concepts
above, and the methods are decorated with the [Given], [When], [Then]
attributes to bind the steps in the feature files.
-- These steps are just a wrapper to the concrete implementation in
the 2 projects below, either for Controller level test or UI.
Which implementation is used is determined at compile time by running
nant copies some files and sets some properties that tells the IoC
Container which implementation to use.
-- Each of the step files implement an interface
For instance, we have this for the user account steps:
[Binding]
public class UserAccountStepsWrapper :
StepsWrapperBase<IUserAccountSteps>, IUserAccountSteps
{
[Given(@"I am in the log in page")]
public void Given_I_Am_In_The_LogIn_Page()
{
Steps.Given_I_Am_In_The_LogIn_Page();
}
...etc.
}
The StepsWrapperBase is simply:
public abstract class StepsWrapperBase<T>
{
protected StepsWrapperBase()
{
Steps = IoCProvider.Resolve<T>();
}
protected T Steps { get; private set; }
}
* Acceptance.Steps.Controller.csproj
- each step file implements the interface defined in the project
above, and the steps will be called if the IoC container has
configured the Controller-level tests components.
* Acceptance.Steps.UI.csproj
- each step file implements the interface defined in the project
above, and the steps will be called if the IoC container has
configured the Browser-level tests components.
- The browser used is also registered in the Castle config file, so we
can also run tests for IE and Firefox if we wish, depending on a
property defined in the IoC framework.
Sorry if my explanation is a bit messy... if time permits and I can
put something more clear in a blog, I will.
Kevin
> mail:
jonas.ba...@gmail.com