File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
src/main/java/com/diffblue/cover/annotations Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 2020import static java .lang .annotation .ElementType .TYPE ;
2121import static java .lang .annotation .RetentionPolicy .RUNTIME ;
2222
23+ import com .diffblue .cover .annotations .exceptions .NoException ;
2324import java .lang .annotation .Repeatable ;
2425import java .lang .annotation .Retention ;
2526import java .lang .annotation .Target ;
8788 * #method()}
8889 */
8990 String returnValueFactory () default "" ;
91+
92+ /**
93+ * @return exception type to throw when the mocked {@link #method()} is called. Defaults to {@link
94+ * NoException} to indicate no exception should be thrown.
95+ */
96+ Class <? extends Throwable > throwException () default NoException .class ;
97+
98+ /**
99+ * @return fully qualified name of the factory method used to create the exception to throw when
100+ * the mocked {@link #method()} is called.
101+ */
102+ String throwExceptionFactory () default "" ;
90103}
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2025 Diffblue Limited.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License").
5+ * You may not use this file except in compliance with the License.
6+ * A copy of the License is located at
7+ *
8+ * https://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * or in the "license" file accompanying this file. This file is distributed
11+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+ * express or implied. See the License for the specific language governing
13+ * permissions and limitations under the License.
14+ */
15+ package com .diffblue .cover .annotations .exceptions ;
16+
17+ /**
18+ * Marker class used to indicate that no exception should be thrown by default in {@link
19+ * com.diffblue.cover.annotations.InTestsMock#throwException()}.
20+ */
21+ public final class NoException extends Throwable {
22+ private NoException () {
23+ // This class should not be instantiated.
24+ }
25+ }
You can’t perform that action at this time.
0 commit comments