Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Test프로젝트는 서비스프로젝트를 참조하여, 서비스내에서 정의한 객체들을 참조를통해

테스트 수행 가능합니다.


테스트를 단위혹은 그룹별실행 가능하며, 출력및

...

유효검사가 편리합니다.



AKKA 유닛테스트 샘플

Code Block
languagec#
themeEmacs
linenumberstrue
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Akka.Actor;
using Akka.Event;

using ServiceA.STUDY;


namespace AkkaTest
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            using (ActorSystem actorSystem = ActorSystem.Create("ServiceA"))
            {
                IActorRef myActor = actorSystem.ActorOf<BasicActor>("myactor");
                Props watchProps = WatchActor.Props(myActor);
                IActorRef watcher = actorSystem.ActorOf(watchProps, "watcher");
                var result = myActor.Ask("나는 살아있다.").Result;
                actorSystem.Stop(myActor); //myActor를 임의로 Stop하여, watcher가 종료를감시한는지 체크
                myActor.GracefulStop(TimeSpan.FromSeconds(10)).Wait();  //생성한 Actor를 안전하게 종료시킨다.
            }            
        }
    }
}

...

No Format
테스트 이름:	TestMethod1
테스트 결과:	성공
Result StandardOutput:	
[DEBUG][2017-09-12 오전 1:29:23][Thread 0022][EventStream(ServiceA)] Logger log1-DefaultLogger [DefaultLogger] started
[DEBUG][2017-09-12 오전 1:29:23][Thread 0022][EventStream(ServiceA)] StandardOutLogger being removed
[DEBUG][2017-09-12 오전 1:29:23][Thread 0022][EventStream(ServiceA)] Default Loggers started
[INFO][2017-09-12 오전 1:29:23][Thread 0022][remoting] Starting remoting
[DEBUG][2017-09-12 오전 1:29:23][Thread 0029][remoting] Starting prune timer for endpoint manager...
[INFO][2017-09-12 오전 1:29:23][Thread 0022][remoting] Remoting started; listening on addresses : [akka.tcp://ServiceA@127.0.0.1:8001]
[INFO][2017-09-12 오전 1:29:23][Thread 0022][remoting] Remoting now listens on addresses: [akka.tcp://ServiceA@127.0.0.1:8001]
[WARNING][2017-09-12 오전 1:29:23][Thread 0022][ActorSystem(ServiceA)] NewtonSoftJsonSerializer has been detected as a default serializer. It will be obsoleted in Akka.NET starting from version 1.5 in the favor of Hyperion (for more info visit: http://getakka.net/docs/Serialization#how-to-setup-hyperion-as-default-serializer ). If you want to suppress this message set HOCON `akka.suppress-json-serializer-warning` config flag to on.
[INFO][2017-09-12 오전 1:29:23][Thread 0004][[akka://ServiceA/user/myactor#1560625506]] BasicActor:GetSomeMessage 나는 살아있다.
[INFO][2017-09-12 오전 1:29:23][Thread 0008][[akka://ServiceA/user/watcher#2126936690]] WatchActor:GetSomeMessage <Terminated>: [akka://ServiceA/user/myactor#1560625506] - ExistenceConfirmed=True
[INFO][2017-09-12 오전 1:29:23][Thread 0008][[akka://ServiceA/user/watcher#2126936690]] 감시대상이 사라짐
[DEBUG][2017-09-12 오전 1:29:23][Thread 0022][ActorSystem(ServiceA)] Disposing system
[DEBUG][2017-09-12 오전 1:29:23][Thread 0022][ActorSystem(ServiceA)] System shutdown initiated



...