Comments (3)
Thanks for the comment. I will add a few tests of this simple type.
from junit-contracts.
I expanded and documented the test cases to use them as examples of how to implement the tests. Please review the documentation link at the bottom of the initial page and the associated code to see if this covers your need. List and the various implementations become very complicated very quickly and were more test code than I cared to write since I would not be using it in any project at this time.
from junit-contracts.
I understand. I find abstract examples like this (A, B, C, D) difficult to understand, so my eyes glaze over when I see them. Others might find them useful.
To use List
as an example doesn't require complete contract coverage. A few examples like these would give people the idea:
class EmptyListContract:
list = createEmptyList(); // abstract
testIsEmpty:
assertTrue(list.isEmpty())
assertEquals(0, list.size())
testIteratorHasNoElements
assertFalse(list.iterator().hasNext());
try {
list.iterator().next();
fail("How did you get a next element?!");
}
catch (NoSuchElementException expected) {}
testCannotGetElement:
try {
list.get(0);
fail("How did you get the first element of an empty list?!");
}
catch (IndexOutOfBoundsException expected) {}
testToArray:
assertArraysEquals(new Object[0], list.toArray(new Object[0]));
That would be enough for people to get the idea, I think.
from junit-contracts.
Related Issues (11)
- Example test for Serializable contract tests everything at once HOT 10
- Does the contract scanning do class initialization HOT 1
- There is no mechanism to skip individual tests in a contract test.
- FastClasspathScanner is outdated -- consider porting to ClassGraph
- Can't build a package from source HOT 12
- ContractSuite fails if there are no tests.
- When parsing WildcardClassFilter single wildcards fail
- Issues on non case sensitive file systems HOT 1
- maven reporting tool needs flag to fail if no classes found HOT 1
- Change 2 logging entries from info to debug HOT 1
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 junit-contracts.