-
Notifications
You must be signed in to change notification settings - Fork 6
A unit test extention.;Making unit testing of POJO's / DTO's / Beans and;Immutable beans easy
IvoNet/beanunit
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
=============================================================================== = beanunit =============================================================================== Is a unit test extension for automated testing of beans. The best way to demonstrate the working of this project is to look at the unit tests. Check out or download the master or one of the latest tags and see for yourself. If you have great ideas for extending or improving the code please contact me. Collaborators are welcome. Cheerz, Ivo. Twitter: @ivonet =============================================================================== - License / Copyright =============================================================================== Copyright 2011-2018 Ivo Woltring Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =============================================================================== = Goal =============================================================================== The goal of this jar is to perform automated useful unit tests on "simple" beans of different kinds. * methods that makes easy work of testing default behavior pojos (beans). * methods for testing beans that are immutable after construction. * Asserts "simple" beans that are constructed using the "Builder" pattern as documented by Joshua Bloch ("Effective Java" - Second Edition). (see builder package in src/test/java) The actual goal is to make useful unit tests for objects everybody hates to test because they seem so easy to make. This way there is much more tested on these simple objects without sacrificing anything. Test coverage is 100% in many cases with almost no effort and I would claim that the tests are useful. =============================================================================== = Prerequisites =============================================================================== * Maven 2 or 3. I build with maven 3 but at this time version 2 also works * Java 1.6 (should there be a 1.5 build to?) =============================================================================== = Rulez =============================================================================== The tests done on the beans are described below... =============================================================================== == Builder =============================================================================== * A Builder has only one constructor * A Builder constructor can have parameters (for mandatory properties) * A Builder has a build() method if no other is provided * Builder methods always have as the return type the Builder itself (this) * After the build method is called the resulting Object is immutable. * Can override equals / hashcode =============================================================================== == POJO =============================================================================== * Default constructor * Bean specification (Getters and Setters for all properties) * if equal method overridden / hashCode method must also be overridden in the same class * if objects are equal the hashCode must also be equal =============================================================================== == Immutable constructed beans =============================================================================== * Must be completely constructed by a constructor * Must only have Getters after construction * Can override equals / hashcode =============================================================================== = Usage =============================================================================== This project is synced to the maven central repository so you can add it as a dependency to your maven project. More explanation here: https://ivonet.github.io/beanunit/ =============================================================================== = Improving / bug fixing =============================================================================== * This project is not under active maintenance, but should be fully functional. The best way to get changes done if you are interested in making it better is to fork the project, make the changes and provide me with a pull request. I will review, incorporate and release the software if the changes are nice. I will also give credit where credit is due. =============================================================================== = Notes =============================================================================== * This project has been an exercise in reflection and has proven useful on a number of occasions. The tests done are actually real tests and usefull tests but this module should not be really nessesary to use IMHO. If you do your testing the correct way all the POJO code should be tested by other unit tests. POJO's should not be Mocked away so all used functionallity should be tested by the classes that use them.
About
A unit test extention.;Making unit testing of POJO's / DTO's / Beans and;Immutable beans easy
Resources
Stars
Watchers
Forks
Packages 0
No packages published