Spring.NET 1.3.0 RC1 for .NET 2.0 API Reference

AbstractDependencyInjectionSpringContextTests Class

Convenient superclass for tests depending on a Spring context. The test instance itself is populated by Dependency Injection.

For a list of all members of this type, see AbstractDependencyInjectionSpringContextTests Members .

System.Object
   AbstractSpringContextTests
      AbstractDependencyInjectionSpringContextTests
         AbstractTransactionalSpringContextTests

[Visual Basic]
Public MustInherit Class AbstractDependencyInjectionSpringContextTests
    Inherits AbstractSpringContextTests
[C#]
public abstract class AbstractDependencyInjectionSpringContextTests : AbstractSpringContextTests

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

Really for integration testing, not unit testing. You should not normally use the Spring container for unit tests: simply populate your objects in plain NUnit tests!

This supports two modes of populating the test:

This class will normally cache contexts based on a context key: normally the config locations String array describing the Spring resource descriptors making up the context. Unless the

SetDirty()
method is called by a test, the context will not be reloaded, even across different subclasses of this test. This is particularly beneficial if your context is slow to construct, for example if you are using Hibernate and the time taken to load the mappings is an issue.

If you don't want this behavior, you can override the

ContextKey
property, most likely to return the test class. In conjunction with this you would probably override the
GetContext
method, which by default loads the locations specified by the
ConfigLocations
property.

WARNING: When doing integration tests from within VS.NET, only use assembly resource URLs. Else, you may see misleading failures when changing context locations.

Requirements

Namespace: Spring.Testing.NUnit

Assembly: Spring.Testing.NUnit (in Spring.Testing.NUnit.dll)

See Also

AbstractDependencyInjectionSpringContextTests Members | Spring.Testing.NUnit Namespace