Make it possible to create unit tests for Actors
See original GitHub issueRight now i can’t create a actor inside a unit test. Take the following Actor code for example
public class TestActor : Actor
{
public TestActor(ActorService actorService, ActorId actorId) : base(actorService, actorId)
{
}
public async Task<string> GetString()
{
return await StateManager.GetStateAsync<string>("Test");
}
}
And using the following unit test:
[Test]
public async Task CanCreateActor()
{
var actor = new TestActor(
new ActorService(
new ActorTypeInformation()
),
new ActorId("Test")
);
Assert.IsInstanceOf<Actor>(actor);
}
When i run the unit test it throws a NullRefference exception
Message:
System.NullReferenceException : Object reference not set to an instance of an object.
Stack Trace:
Actor.ctor(ActorService actorService, ActorId actorId)
TestActor.ctor(ActorService actorService, ActorId actorId) line 12
IAMEmployeeTest.CanCreateActor() line 19
GenericAdapter`1.GetResult()
AsyncToSyncAdapter.Await(Func`1 invoke)
TestMethodCommand.RunTestMethod(TestExecutionContext context)
TestMethodCommand.Execute(TestExecutionContext context)
SimpleWorkItem.PerformWork()
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
How to unit-test an actor that gets a reference to another ...
Inject an ActorProxyFactory into the calling Actor constructor, and use that to create ActoryProxy instances. Like shown here or here.
Read more >Writing tests for actors — Leapp 0.15.1 documentation
Tests are considered being part of the actor and we do not only encourage but basically require you to write tests if you...
Read more >Chapter 3. Test-driven development with actors - Akka in Action
The test kit provides a TestActorRef that allows access to the underlying actor instance. This makes it possible to test the actor instance...
Read more >Unit Tests with Actor Framework - NI Community
I use the JKI VI Tester to unit test my actors. I test the public interface. I use the init methods in the...
Read more >Testing Classic Actors - Documentation - Akka
The actor model presents a different view on how units of code are delimited and how they interact, which influences how to perform...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Keeping this open for tracking more improvements to making actor unit tests
@malotho I would suggest to keep it open to track more improvements needed in SDK itself to make it easier to write unit tests.