我正在使用Karma和茉莉花进行单元测试。如何测试方法对其他方法的函数调用?我是否在茉莉花中使用间谍?
Ticket.controller.controller.js
import numpy as np
a = np.array([1,2,3,4,5,6,7,9,0])
print(a) ## [1 2 3 4 5 6 7 9 0]
print(a.shape) ## (9,)
b = a[:, np.newaxis] ### want to write this in tensorflow.
print(b.shape) ## (9,1)
Ticketcontroller.controller.test.js(测试文件)
function hello()
{
test();
test1();
}
答案 0 :(得分:0)
您只需观看并通过它们致电:
spyOn(controller,'test').and.callThrough();
spyOn(controller,'test1').and.callThrough();
controller.hello();
expect(controller.test).toHaveBeenCalled();
expect(controller.test1).toHaveBeenCalled();