# JSON-Java-unit-test
Unit tests to validate the JSON-Java GitHub project code
https://github.com/douglascrockford/JSON-java
*These tests are a work in progress. Help from interested developers is welcome.*
More coverage is needed, but more importantly, improvements to test quality is needed.
Test harness: http://junit.org
Coverage: http://www.eclemma.org/
Eclipse is the recommended development environment.
Run individual tests or JunitTestSuite using *EclEmma Coverage*, or execute the TestRunner application directly.
Test filenames should consist of the name of the module being tested, with the suffix "Test".
For example, Cookie.java is tested by CookieTest.java.
When adding a new unit test, don't forget to update JunitTestSuite.java.
The fundamental issues with JSON-Java testing are:
* JSONObjects are unordered, making simple string comparison ineffective.
* Comparisons via **equals()** is not currently supported. Neither JSONArray nor JSONObject overrride hashCode() or equals(), so comparison defaults to the Object equals(), which is not useful.
* Access to the JSONArray and JSONObject internal containers for comparison is not currently available.
* JSONObject sometimes wraps entries in quotes, other times does not, complicating comparisons.
When you start working on a test, add the empty file to the repository and update the readme, so that others will know that test is taken.
A unit test has the following stages:
|No test|
|In progress|
|Coverage > 90%|
|Reasonable test cases|
|Checked against previous unit tests|
| Test file name | Coverage | Comments |
| ------------- | ------------- | ---- |
| Total coverage | 88.6% | | |
| | | |
| CDLTest.java | 98% | Reasonable test cases. |
| CookieTest.java | 97.5% | Coverage > 90% |
| CookieListTest.java |96.5% | Coverage > 90% |
| HTTPTest.java | 98.7%| Coverage > 90% |
| HTTPTokener.java |93.2% | No test |
| JSONArrayTest.java |95.9% | Coverage > 90% |
| JSONException.java | 26.7% | No test |
| JSONMLTest.java | 83.2%| In progress |
| JSONObjectTest | 90.9% | Coverage > 90% |
| JSONObject.Null | 87.5% | No test |
| JSONString.java | | No test |
| JSONStringerTest.java | 93.8%| Coverage > 90% |
| JSONTokenerTest.java | 72.1% | In progress |
| JSONWriter.java | 88.9% | No test |
| PropertyTest.java | 94.8% | Coverage > 90% |
| XMLTest.java | 85.1% | In progress |
| XMLTokener.java| 82.7%| No test |
| Files used in test |
| ------------- |
| JunitTestSuite.java |
| MyBean.java |
| StringsResourceBundle.java |
|TestRunner.java |
| Util.java |