Timeout Unit Test

Malcolm
2014-03-18
2014-03-18
  • Malcolm - 2014-03-18

    Hello,

    when I perform a Unit Test with an IF-loop with multiple runs (> 1000, used in the method prvCyclicAction) my test breaks off after about 40s due to timeout.

    How can I prevent it with the same number of passes?

    Regards,
    Malcolm

     
  • Anonymous - 2014-03-18

    Originally created by: M.Schaber

    Hi, Malcolm,

    Malcolm hat geschrieben:
    when I perform a Unit Test with an IF-loop with multiple runs (> 1000, used in the method prvCyclicAction) my test breaks off after about 40s due to timeout.
    How can I prevent it with the same number of passes?

    I have to admit I'm a little bit confused by your question.

    First, there is no IF-loop. An if-construct is not a loop, as it does not have any repetitions, it only provides conditional execution.

    Second, you should not use long-running loops in code which runs in the IEC task cycle. You will exceed the tasks cycle time, and block all other operations (like other tasks, refreshing of inputs and outputs, and communication with CODESYS).

    You need to "inverse" the logic of thinking here: your code is already running in a loop (the task cycle), so within the prvCyclicAction method, just perform a single pass of your loop. This may look strange, but it is the IEC-61131 way of thinking.

     
  • Malcolm - 2014-03-18

    M.Schaber hat geschrieben:
    First, there is no IF-loop. An if-construct is not a loop, as it does not have any repetitions, it only provides conditional execution.

    Sorry fΓΌr the confusion. I have an if-construct with an inner if-construct which resets in a specific condition nCycle.

     
  • mkeller - 2014-03-18

    Hi Malcolm.

    Okay, that makes sense.

    I think your problem could be the default timeout of 15 seconds for a test case. You need to specifiy a bigger timeout by adding the following attribute to the declaration of the test POU:

    {attribute 'testcasetimeout' := '3600000'}
    

    The specified string for the timeout must be convertable to an 32-bit signed integer. For example '3600000' for an 1 hour (= 3600000 ms) timeout.

    Regards,
    Martin

     
  • Malcolm - 2014-03-18

    Hi Martin,

    thank you for your solution. That's exactly what I was looking for. Now it works perfect.

    Regards,
    Malcolm

     

Log in to post a comment.