是否有与 anyInt()、anyString() 等等效的方法来检查参数是否属于特定(非通用)类型?
Is there an equivalent to anyInt(), anyString(), etc. for checking a parameter is of a particular (non-generic) type?
如果将泛型类型作为参数传递给模拟方法,使用 anyInt()
、anyChar()
、[=12 等方法很容易生成相同的响应,而不管其值如何=],等等
是否可以在参数必须是特定类型的对象的情况下执行此操作?
(例如,anyCar()
、anyVehicle()
等)
匹配器 isA(Class<T> clazz)
提供此功能。
例如 -
isA(Car.class)
, isA(Vehicle.class)
如果将泛型类型作为参数传递给模拟方法,使用 anyInt()
、anyChar()
、[=12 等方法很容易生成相同的响应,而不管其值如何=],等等
是否可以在参数必须是特定类型的对象的情况下执行此操作?
(例如,anyCar()
、anyVehicle()
等)
匹配器 isA(Class<T> clazz)
提供此功能。
例如 -
isA(Car.class)
, isA(Vehicle.class)