I am a relative newbie to testing Akka actors. I am in the process of writing some unit tests. However I need more direction.
To accomplish my goal, I would like to unit test the following Actor whose description I have laid out below:
class ActorWithFileHandlingCapabilities extends an Actor with a FileActionable trait Description: I am trying to test an Actor class that is peering into a directory, and inspecting the files inside of it. This action of the actor, I call it, a "task". The class extends an Actor with a FileActionable trait This class field variables a follows: 1) A val "taskID" 2) An ActorRef 3) an anonmymous function that takes takes into in a parameter - a val of type FileMetaDataInfo, and returns a Future[MetaDataAssociatedWithActionsTakenOnFile] which is stored in a val that I call: postActionsTakenOnFileFunction
Note: MetaDataAssociatedWithActionsTakenOnFile is a case class and represents a few things like, when the file was last worked on, what is the file path, a flag to indicate something was detected in the file, no of characters in the file, etc]
def initializeActionsTakenOnFile(filesList:List[FileMetaDataInfo ) : Option[Int] = { some code, that basically checks the List.headOption to explicitly handle the case of an empty list, does some logic that basically decides if the Actor how it would decide to exercise actions on the files based on some prior load metric or something. }
[Note: filesList represents a List of case class entities representing metadata like file path, when the file was last modified, the length of the file>>
Then of course, I have a receive method that basically goes through some cases and has a case message to log an error reporting something it cant handle..
----------------------------------------- I would like to know what testcases I can possibly write and how a test case or case code will look. I am studying up on the ScalaTest site and also the Akka documentation on testing actors. But I would like to write testcases using ScalaTest.
--------------
I have already taken a stab at writing the unit test. Here it is:
class FileProcessorUnitTest extends FunSpec with ShouldMatchers {
ignore ("actor should handle every single file separately on threads running concurrently") {}
ignore ("actor should manage its own load") {}
ignore ("actor should come up with stats") {}
implicit val _fpSystem = ActorSystem("FileHandlerTestSystem")
class testFileHandlerActor extends Actor with FileHandling {
}
}
FileHandling is a trait. How do I continue from this point on? What is the approach? Is the trait somehow involved in the testing as well? Sorry if my questions are naive, but I would like to bungle and start somewhere..
you wrote quite understanding test cases have you ever tried with automation testing it is good after making a test case plan you can put your software on an automation phase do my college homework for me I was not good at writing test case plan first but when I start internship so I get so handy in a few days. now I can easily write test cases