Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
Randy Strauss
Randy Strauss am 12 Mai 2020
Kommentiert: Tommy am 14 Mai 2020
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 Kommentar
Tommy
Tommy am 14 Mai 2020
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');

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Mock Dependencies in Tests finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by