-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Beanoh.NET, pronounced 'beanˌōˌdotˌnet\ , is a simple open source way to verify you Spring.NET context. Teams that leverage Beanoh spend less time focusing on configuring Spring.NET and more time adding business value.
For licensing information refer to the license section.
- Verify that all of your objects are wired correctly
- Prevent duplicate object definition overwriting
Beanoh.NET is for verifying Spring.NET contexts, so naturally it depends on Spring.NET. More specifically, Spring.Core, Spring.Aop and Spring.Data. Moreover, it also depends on Castle.Core for proxying, Common.Logging for logging, Moq for mocking and more importantly NUnit as the implementation framework of the Beanoh.NET test fixtures.
For Licensing information of those dependencies :
- Castle.Core : Apache License V2.0 (http://www.apache.org/licenses/LICENSE-2.0.html)
- Common.Logging : Apache License V2.0 (http://www.apache.org/licenses/LICENSE-2.0.html)
- Moq : BSD License (http://opensource.org/licenses/bsd-license.php)
- NUnit : http://nunit.org/index.php?p=license&r=2.5
- Spring.NET : Apache License V2.0 (http://www.apache.org/licenses/LICENSE-2.0.html)
Beanoh.NET tries to follow a simple convention so that you will spend less time learning Beanoh.NET and more on gaining the feedback it provides. The convention in question is that your NUnit test fixture needs to extend the base SourceAllies.Beanoh.BeanohTestCase test fixture, and writing one Spring.NET bootstrap context that loads all the contexts you need to verify. That bootstrap context need to be in a certain location and named in a certain way for it to be picked up by Beanoh.NET. We will talk about those requirements shortly.
For example, let's say we want to verify a Spring.NET context found in assembly://MyAssembly/My.Cute.Namespace/someSpringContext.xml that defines objects and wire them together and it can possibly be loading other contexts in its turn. First we create a NUnit Test Fixture, let's call it BasicWiringTest, and it needs to extend SourceAllies.Beanoh.BeanohTestCase test fixture.
//Our Code will look like this
namespace My.Tests.Verbose.Namespace
{
[TestFixture]
public class BasicWiringTest : BeanohTestCase
{
[Test]
public void TestWiring()
{
AssertContextLoading();
}
}
}
To make a simple verification that every object definition in our Spring.NET context is being loaded, all we need is to define a test method TestWiring() that just calls BeanohTestCase.AssertContextLoading() method.
Next, we need to define the bootstrap context that we were talking about earlier. For now all you need to know about is that it needs to satisfy the following criteria :
-
It's to be named
X-BeanohContext.xml. WhereXis the name of your Test Fixture class, hence for our example the context name isBasicWiringTest-BeanohContext.xml. -
It needs to live in the same assembly as our test fixture.
-
It needs to be in the same folder as our test fixture so that it will have the same namespace as the test fixture.
-
It needs to be defined as an embedded resource so it will be copied along with our test fixture during compilation and execution.
Now, you can just run the test and let Beanoh.NET do its magic.
Something to point out is when the bootstrap conforms to these criteria, the effect will be that when you build your test assembly, you will find the test fixture class and the context living together in the same namespace in the generated DLL. Hence, if you have issues with running the test and you get a message saying couldn't find context, then your first troubleshooting task should be to inspect the tests assembly DLL and check that the bootstrap context and test fixture have the same namespace. You can inspect the DLL using tools like CodeReflect.
Note: In future Beanoh.NET releases, we might add some flexibility around how to define the bootstrap context once we get a better understanding how Beanoh.NET users want that to be.