Comments (2)
The reason I'm not in love with this feature is that I never liked the JUnit's expect
attribute. In my opinion, the tests are less readable with it, and a lot more fragile (I've often seen tests that passed, but the actual Exception was not thrown from the line that the author intended, and so they were in fact 'false positives').
As long as Specnaz doesn't have this feature, it forces people to look for alternatives - which is great, because a lot of alternatives exist, and they are all better than JUnit's expect
:
- If you're using AssertJ for assertions, you have the assertThatThrownBy method for that exact scenario.
- There is the CatchException library, tailor-built for this purpose.
- Probably many others that I'm forgetting right now.
Design-wise, I don't see a problem with this feature. I would probably make the API look something like:
it.shoudThrow(IllegalArgumentException.class, "when called with a null argument", () -> {
// the test name will be: "should throw IllegalArgumentException when called with a null argument"
// ...
});
The perfect API would probably be:
it.shouldThrow<IllegalArgumentException>("when called with a null argument", () -> {
// ...
});
..but I'm not sure that's possible with Java. I do know that KotlinTest does something like this, so perhaps that will be the API in the Kotlin version.
The only question is: do we want to do this, or do we rather skip this, forcing people to look for (better) alternatives?
from specnaz.
Fixed in 1.1 - resolving.
from specnaz.
Related Issues (10)
- Better Mockito integration HOT 2
- Specnaz TestNG runner fails, by trying to run *describes lambdas as test (and failing at it) HOT 3
- When we get an unexpected exception Specnaz should print full message/stacktrace for it HOT 6
- Problem with Maven HOT 3
- formatParamsDesc not sanitizing input HOT 3
- Top-level description missing from terminal output when running tests HOT 2
- Fail on no tests found? HOT 2
- Support for top-level `fdescribes`? HOT 3
- Testing multiplatform code? HOT 10
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 specnaz.