From 88fddf2bcc178ca2654b88ccebf9ec7c346ed0ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E6=88=9F?= Date: Sat, 7 Nov 2020 23:24:53 +0800 Subject: [PATCH] allow to check method never invoke with parameters --- .../testable/core/tool/InvokeVerifier.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/testable-core/src/main/java/com/alibaba/testable/core/tool/InvokeVerifier.java b/testable-core/src/main/java/com/alibaba/testable/core/tool/InvokeVerifier.java index e67f252..cdf9bb4 100644 --- a/testable-core/src/main/java/com/alibaba/testable/core/tool/InvokeVerifier.java +++ b/testable-core/src/main/java/com/alibaba/testable/core/tool/InvokeVerifier.java @@ -90,6 +90,24 @@ public class InvokeVerifier { return this; } + /** + * Expect mock method had never invoked with specified parameters + * @param args parameters to compare + */ + public InvokeVerifier without(Object[] args) { + for (Object[] r : records) { + if (r.length == args.length) { + for (int i = 0; i < r.length; i++) { + if (!r[i].equals(args[i])) { + break; + } + } + throw new VerifyFailedError("was invoked with " + desc(args)); + } + } + return this; + } + /** * Expect mock method have been invoked specified times * @param expectedCount times to compare