6

Can somebody show an example how to use Akka.Net Testkit with F# API? Both Akka.Net and F# are quite new to me so I don't know if it is even feasible or reasonable to write unit tests this way (F# API and Testkit). To be more specific, quite simply I don't know how to get access to Sys with F# API. This is what I got:

module SocketTests
open Xunit
open Akka.TestKit
open Akka.TestKit.Internal
open Akka.TestKit.Xunit2
open Akka.FSharp

type SocketTests() =
    inherit Akka.TestKit.Xunit2.TestKit()


    [<Fact>]
    let Socket_should_change_to_connected_state_when_receiving_Connect() =

Ok, now I would need to get reference to Sys for spawning something and for the life of me I can't figure it out. :-(

Any help would be much appreciated

2
  • 2
    You would need to make your test an instance method to have access to Sys (so using member instead of let). Akka.FSharp doesn't have a dedicated testing API - if you need one you may use Akkling or just copy Akkling.TestKit helpers - it's a single file, minor type definition changes are necessary to make it working with Akka.FSharp. Sep 20, 2016 at 9:11
  • Excellent, Akkling + the TestKit helpers is just what I need. Thanks for creating it. Sep 20, 2016 at 9:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.