Assertion coloring
Conformance test development involves identifying assertions in a specification, writing conformance tests that check the identified assertions and linking the test to the assertion that it tests.
Lets start from the following points:
- assertion is marked
- actual assertion is difficult to view in the spec (currently there are only small assertion gif’s at the end of each assertion)
- complete assertions are only viewed by reading the html directly or looking at each individual test
- start of assertions are difficult to see in the html code
- providing a visual way to view the assertion easily is teh problem we are trying to solve.
The main point is to color the assertions (specification text itself) using html tags. The research was made which html tags to use. Div, span, table and font tags were looked at. The best solution is the font tag. So the text is surrounded with font tags. The class attribute of the font tag corresponds to the type of the assertion. F.e. if the asserion is new it is colored with red, to indicate, that tests need to be written, old assertions are colored with green to indicate that tests already exist. There should be a utility (script or java program) to scan marked up specification and automatically add the tags needed for coloring. The background color of the text will be determined by the title attribute color of the assertion. This method was implemented and works fine. For usability purposes, there should be a mechanism to hide coloring, f.e. a javascript.
A disadvantage of this solution is that the color is static since it is based on the title attribute. A second solution would be that the tool would check for an existence of a test (based on the assertion id or link in the assertion). If a test exists, we would do something to set the color of that assertion. It could be as simple as setting a title attribute. A disadvantage to this solution would be that the assertion coloring would be still static, but based on when the user run the scripts.
A variation on the given solution is that we would dynamically generate the coverage data when the spec is viewed in a browser. We would determine if a test exists in the test directory for a given assertion and color the assertion accordingly. This could be done through a javascript/vbscript using objects, that allow accessing file system. This method would be dynamic and should always have the latest assertion coverage status.
Here are some examples from JLS3 chapters “Conversions and Promotions” and “Interfaces” :
Assertions conv063, conv047, conv065, conv48, conv66 and conv049 are from previous version of spec, they weren’t changed and tests update is not needed – color is aquamarine (neurtal green). Conv155 and conv156 are new, new tests should be developed, assertions are colored in glaring red. Conv064 was changed, test update is necessary – color orange. Annot019 is a new one, tests exist, but they are needed to be changed – salmon color. Annot020 is new, but кудумфте tests exist – color light green.
The main advantage of spec coloring is that the spec is visualized. User can see the whole assertion and its title. One can tell by looking at the spec, where there are areas with low coverage, where some or lots of tests should be added or changed. There is basically the possibility to see how well a spec is marked up and how well it is tested.
assertion, color, conformance, Java, JLS, spec, specification, tests
Especially when different people and companies understand the situation around them in different ways. So let’s start from the very beginning.
Well, let’s say this new language was used to create a program for stock exchange. Imagine it was written in the US, well tested and used at NYSE. It was so good, that other countries all over the world bought a license and started using it on their implementation of this new language. If an implementation didn’t obey the spec, the same program might do different things with clients’ money. Basically this stock exchange program might sell when commercial agent pushed the “buy” button, or buy steel instead of fruit.
Let’s move towards an example. Sun Microsystems invented Java language. To be more precise several versions of Java for different markets were created. The most famous are ,