LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Examples of Actor Testing

Has anyone come across some modern (i.e. last few years) examples of testing both root and nested actors in AF? I've seen a few things from early versions of AF. What does it look like when you use abstract messages? Do you need to define child messages within your test application?

 

Any other tips on testing actor code?

0 Kudos
Message 1 of 6
(2,458 Views)

I usually write a test harness actor that acts as a Root Actor to talk to Child Actors that I want to debug or test. It'll just send simple messages and display simple data. I don't have any good examples available unfortunately. Just ask "What does my actor need to do with [data]?" Make a simple Root actor you can launch, then send that to the Child and see if the Child responds appropriately.

 

Abstract actors generally don't do "real work"- they just provide message templates for Concrete actors to override. They wouldn't really need "functional" testing in that case since they should just do nothing.

 

If they ARE doing some work, you can just send them some dummy data and see if they act correctly.

 

For testing, I can't recommend MGI's Monitored Actors enough. You will be able to actually inspect the specific Actor Core clone of the Actor you just launched, and can use Probes like you would on any other VI. (Typically it's something of a pain to see the actual clone instance of an Actor Core vi- you have to open the Actor Core.vi base VI you're calling, then Tools->Browse Relationships->Reentrant Instances to select the one you're looking for)

Message 2 of 6
(2,451 Views)

Thanks for this and your other post, it gives me a lot to think about. I think I just implemented something similar to what you described for testing an actor.

0 Kudos
Message 3 of 6
(2,447 Views)

Can you launch an actor you designed as a nested actor, as a root actor without a caller? Can you test this way, or must a nested actor always have a caller actor to ensure various queues and stuff behave properly.

0 Kudos
Message 4 of 6
(2,409 Views)

Whether or not an actor is "nested" is defined by how you launch it. If you use "Launch Root Actor" then it's a Root, if you use Launch Nested Actor then it's a Nested 🙂

 

The only real difference (from the POV of the launched actor, as far as I'm aware) is that a Root actor will not be able to return a Caller actor from within the Actor itself using the "Read Caller Enqueuer" function. There may also be some issues with automatic stopping if you're depending on a Caller stopping the Root actor (if you do this, there would be no way to stop the actor as it's expecting to be stopped by the caller closing as opposed to a dedicated message).

 

There may be some more nuanced details, but I think the "Read Caller Enqueuer" is the only major, actor-level difference. There may be differences in your specific implementation though that make it impossible to launch a Nested actor as a Root; generally, Nested actors will send their caller messages as they do their work. If they're fairly standalone it's fine, otherwise you'll need a way to set up return queues for the actor under test to send messages to. The simplest way is to just make a barebones testing Root actor but I think there's a debugging VI somewhere in the AF pallette that lets you do some actor stuff from test code, but it's marked specifically for use in testing only. I haven't used it myself.

0 Kudos
Message 5 of 6
(2,389 Views)

Thanks, that gives me a few pointers to dig into. I'll leave this open to see if anyone points out an example or two.

0 Kudos
Message 6 of 6
(2,384 Views)