unit testing

mhisted's Avatar


09 Mar, 2018 03:13 PM

Hi Chris,

Is there any way to spin up MWorks with a Workspace file, and run a specified number of trials, incl. Matlab and Py bridges? Best would be the ability to specify a variable file on the command line (or I could edit the workspace file), and run headless. Do you do this sort of thing?


  1. Support Staff 1 Posted by Christopher Sta... on 09 Mar, 2018 03:25 PM

    Christopher Stawarz's Avatar

    Hi Mark,

    We do have a tool for unit testing (/Library/Application Support/MWorks/Developer/tests/MarionetteTest.app). However, it doesn't use the MWClient application. Instead, it uses the core mw::Client class to interact with an MWServer instance. It's also kind of terrible, and I wouldn't recommend trying to use it for anything.

    At present, the MWClient app doesn't support any kind of automation. I've considered adding AppleScript support to it, but I suspect that wouldn't see much use.

    Can I ask what you'd like to accomplish? Are you really interested in unit testing your experiments, or are you thinking more about automating regular runs?


  2. 2 Posted by mhisted on 11 Mar, 2018 04:57 PM

    mhisted's Avatar

    Hi Chris,

    Yes, I'm trying to unit test experiments. When you come down here, I can show you in more detail our setup and discuss why. (Basically it's because (1) without local scoping or functions, it's really hard to make sure changes don't break things elsewhere; we often have 10-20 animals running on an expt with different variable values at any given time and (2) my external device control can be a little flaky and benefits from testing.)

    For that testing, I'd like to be able to provide a variables file, XML file, Python bridge file and MATLAB file, and have the server run that experiment for some amount of time.
    I don't think it's worth you spending time to make that work. Let's put it on hold till you visit.

    On a related note, I recently saw some discussions of how best to build state machines in Python:
    this on Javascript (similar ideas in py) http://raganwald.com/2018/02/23/forde.html <http://raganwald.com/2018/02/23/forde.html>
    There's a design patterns summary: http://python-3-patterns-idioms-test.readthedocs.io/en/latest/StateMachine.html <http://python-3-patterns-idioms-test.readthedocs.io/en/latest/StateMachine.html>
    And the library from Tal Yarkoni: https://github.com/pytransitions/transitions <https://github.com/pytransitions/transitions>
    I know you've made the argument that defining a state machine in python would be difficult/impossible for most MWorks users. For what my group does, I still think the best soln for us going forward is to replace xml/mwel with python. But I don't have much time to think about that these days. We can talk about this again in person sometime.


  3. Christopher Stawarz closed this discussion on 24 Jul, 2018 01:22 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac