Comments (10)
We are using AssertJ now, so you can easily write custom assertions for your business exception http://joel-costigliola.github.io/assertj/assertj-core-custom-assertions.html.
Please show your code for catch-exception before 1.4.2.
I take look into Intellij warning...
from catch-exception.
Ok, custom assertion dosent help here. I need to think about this :) Thanks for the report
from catch-exception.
I have only one solution to this problems ->
mariuszs@2b9ff7a
thenCaughtException()
.isInstanceOf(IndexOutOfBoundsException.class) //
.hasMessage("Index: 1, Size: 0") //
.hasNoCause();
thenCaughtException
is using AssertJ api
from catch-exception.
Fixed in #27
from catch-exception.
I leave old behaviour for Java 6 and 7, for Java 8 this is not working, my proposition for java 8:
when(service).doSomething();
then(caughtException((BusinessRuleException.class))
.isInstanceOfAndGet(BusinessRuleException.class)
.getCode().isEqualTo(MY_ERROR_CODE);
from catch-exception.
Is clearly better, but
then(caughtException(BusinessRuleException.class))
.isInstanceOfAndGet(BusinessRuleException.class)
still very much looks like code duplication. isInstanceOfAndGet()
should be automatically done inside the then(caughtException())
or similar.
from catch-exception.
You are absolutly right, but I dont know how to do that (for Java8).
http://stackoverflow.com/questions/29499847/ambiguous-method-in-java-8-why
from catch-exception.
You can do something like this
from catch-exception.
Can we get a non-generic version of caughtException() added?
At moment the signature is
public static <E extends Exception> E caughtException()
java 8 is now more strict, and requires the caller to define that type. Where method overloading means multiple parameters could match, you now get the ambiguity error.
for most of the assert frameworks, we just want to pass Exception in. so it would be handier if the method signature was just:
public static Exception caughtException()
Which would remove the ambiguity. To avoid breaking existing code, could either add non generic method with different name, or create a new parallel class that doesn't use the generics.
from catch-exception.
Sorry for delay, I have missed your answer,
I have added Exception caughtException()
to BDDCatchException
Btw, we can use something like org.assertj.core.api.AssertionsForClassTypes
in Java8 with non-generic caughtException()
.
from catch-exception.
Related Issues (19)
- Buid failed on JDK8
- Package change for BDDCatchException? HOT 3
- Add support for Mockito 1.10.9+ HOT 19
- BDD-like assertions don't work with Java 8 HOT 4
- VerifyError on verifyException HOT 3
- Fix compatibility issue with Mockito 1.10.8
- Better integration with AssertJ 2.0 HOT 4
- Catch-Exception 2.0 Ideas HOT 5
- outdated documentation HOT 3
- Coverage status icon 404 HOT 3
- Which Maven dependency should I use? HOT 1
- JaCoCo agent shouldn't be activated on every build HOT 10
- Fails to forward .call() method properly
- Better error when mocking a final class HOT 1
- NullPointerExceptions after catchException() HOT 2
- Mockito spies call real methods instead of stubs with catchException HOT 2
- Handling runtime exceptions HOT 2
- Consider making repo read only (archived now)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from catch-exception.