The Artima Developer Community
Sponsored Link

Actors in Scala Forum
Writing test cases in ScalaTest - pointers requested

1 reply on 1 page. Most recent reply: Apr 6, 2019 12:49 AM by angila lee

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Han Wei

Posts: 2
Nickname: akkathinke
Registered: Feb, 2015

Writing test cases in ScalaTest - pointers requested Posted: Feb 7, 2015 8:46 AM
Reply to this message Reply
Advertisement
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]


I have the following methods:


def postActionsTakenOnFile(<<a file>>, <<report>>) = postActionsTakenOnFileFunction



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..

Any pointers are appreciated. Thanks in advance.


angila lee

Posts: 1
Nickname: angila
Registered: Apr, 2019

Re: Writing test cases in ScalaTest - pointers requested Posted: Apr 6, 2019 12:49 AM
Reply to this message Reply
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

Flat View: This topic has 1 reply on 1 page
Topic: How to fix HP printer Scanner Error code 22? Previous Topic   Next Topic Topic: [Fixed]How to Solve the QuickBooks Error 6130, 0?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use