How does one use AssertCalled (when testing with mock objects)?

조회 수: 1 (최근 30일)
Randy Strauss
Randy Strauss 2020년 5월 12일
댓글: Tommy 2020년 5월 14일
This form keeps hanging on me, so I'll paste an image from the previous (hung) session:
Basically, I'm guessing the mock object is the "behavior".
That doesn't seem right, but that page gives no other clue...
The generate function is declared as:
function [trajectory] = generate(this) %#codegen
That is, it's a public class function with no other inputs except the mandatory first parameter.
How do I get this to work?
  댓글 수: 1
Tommy
Tommy 2020년 5월 14일
I may be misunderstanding the docs but it seems like you need to request the matlab.mock.MethodCallBehavior object when you call createMock:
[generator, behavior] = this.createMock(?TrajectoryGenerator, ci, {this.simParams, this.simState});
and then
this.assertCalled(behavior.generate(), 'a string');

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Mock Dependencies in Tests에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by