Hi, I am running into a small issue with justmock. I am using nunit as my testing framework which allows base classes with multiple TestFixtureSetup methods when running a single test. I will create and inject my common mocks in the base class TestFixtureSetup method. Then my test class(inheriting the base class) will do the arranging and testing.
The issue is when the method being mocked is called, it acts like the arrange never excuted. I can verify that all the code ran in the order expected, but my mocked methods are just returning nulls.
Below I have a simple example of what I'm trying to explain.
This does work when the test class has a TestFixtureSetUp of its own and calls the base class setup method, but the base class setup method cannot have the TestFixtureSetUp attribute. Does this mean that the arrange has to execute within the same fixture as the create?
Is there a better way to utilize a base class in this manner? Is this intended?
On a side note, this method was working a couple days ago when I had checked my code in. I will revert my tests to see if i stumbled upon some way to get this to work, I may have had the attributes in just the right places possibly?
The issue is when the method being mocked is called, it acts like the arrange never excuted. I can verify that all the code ran in the order expected, but my mocked methods are just returning nulls.
Below I have a simple example of what I'm trying to explain.
[TestFixture]
public
abstract
class
TestBase
{
public
IClientService ClientService;
[TestFixtureSetUp]
public
void
InitFixture()
{
ClientService = Mock.Create<IClientService>();
}
}
[TestFixture]
public
class
ClientServiceTests : TestBase
{
[Test]
public
void
Test()
{
Mock.Arrange(() => ClientService.Retrieve(Arg.AnyLong))
.Returns(() =>
new
Client());
var client = ClientService.Retrieve(0);
Assert.IsNotNull(client);
}
}
This does work when the test class has a TestFixtureSetUp of its own and calls the base class setup method, but the base class setup method cannot have the TestFixtureSetUp attribute. Does this mean that the arrange has to execute within the same fixture as the create?
Is there a better way to utilize a base class in this manner? Is this intended?
On a side note, this method was working a couple days ago when I had checked my code in. I will revert my tests to see if i stumbled upon some way to get this to work, I may have had the attributes in just the right places possibly?