Assertion coloring

rainbow Assertion coloringConformance 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” :

JLS3 colored Assertion coloring

JLS3 colored2 Assertion coloring

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.



, , , , , , ,
       

    Markup metadata

    11 Markup metadataThe simplest definition of metadata is that it is data about data. Metadata might be very useful. As for the markup there was some metadata embedded: id, small description of assertion, link to test. During the markup transfer I realized that more metadata would be very helpful. In the new version of specification there were several kinds of assertions:

    • old:
      non-changed text, tests do not need any changes;
    • oldToBeChanged:
      text changed, tests do need to be changed;
    • new:
      totaly new text, new tests needed;
    • newWritten:
      new text, but tests already exist (because the test development process began as soon as the draft spec was avaliable);
    • newWrittenToBeChanged:
      new text, tests exist, draft spec changed, so the tests need to be changed or existing tests are not enough.

    Adding this kind of data to the markup would greatly simplify the future work – the test development. Because just by looking at an assertion in the spec one can easily say if more tests are needed or several should be updated.

    With the given markup architecture is was decided to use the title attribute in a-href tag (the second anchor). So the markup would look like:

    <a name=assertionID><!– shord description as html comment –>
    assertion statement here
    <img src=”pics/assert.gif”><a href=”path to test” title=assertType>test ID which is the same as assertion ID</a>

    The title attribute can be viewed in a browser as a hint.

    JLS3 html Markup metadata

    JLS3 html code Markup metadata



    , , , , , , , , , ,
         

      Markup transfer – nightmare or a piece of cake?

      train Markup transfer   nightmare or a piece of cake?
      The whole process of creating a markup and developing tests is time consuming. And when it seems that the work is done, a new version of spec is released. What happens next? Of course there is a need of a new version of the test suite. New tests must be written and the old ones updated or even deleted.

      The best way to start is to do the markup. This task can be devided into two subtasks:

      • transfer old markup from previous spec to the new spec (this is needed because many tests were already  written, they are linked to spec id’s, reusing all possible tests is a good idea);
      • markup new and updated assertions.

      Transferring the markup is simple enough to do it by hand:

      1. Find the markup tag in the old spec.
      2. Find the best place to insert the tag in the new version of spec.
      3. Insert the tag.

      If there are only 10 assertions – this work is a piece of cake. But if there are thousands it is a hard job that should be automated. The hardest part is to find a new proper place for markup tags. It’s hard just because the spec was changed. For JLS2 to JLS3 migration process the flollowing alrorithm was used:

      Each assertion is rounded with html anchors. Both of them should be transferred using such algorithm.

      Hin 1t: if some tag is transfered, there is a great possibility, that next tag in old spec will be positioned after the one that is transfered.

      Hint 2: algorithm should check that the second anchor should be positioned after the first one and not too far from it.

      1. Look at the text before and after tag in old spec. Find it in the new spec. If one of them72s Markup transfer   nightmare or a piece of cake? wasn’t changed – the answer is found. usually the length should be 1-2 sentances, at least 60 characters long. If none or several sentances found – skip this step.
      2. Try to do the same as in (1), but remove all html tags from the near text that surrounds the tag. If none found – skip this step.
      3. Try the adopt algorithm, which tries to find similar text in the new spec.
        a. Use steps (1) and (2), but desrease the length of the searching text in a loop until the sentance is found or the length is too short. The practical work showed that this number shouldn’t be less than 20.
        b. If steps (1) and (2), or (3a) found several sentances increase the length of the text to search until the text is found in the new spec or the upper limit (f.e. 140 chars) is reached. Use hints to find the best matching text.

      Adopt algorithm could be used with both ignoring html tags and taking advantage of them. Algorithm is valid for specs written in plain text, html or xml.

      This algorithm was implemented in JLS2->JLS3 markup transfer tool. 84% of the markup tags were transfered automatically. The rest of them were done manually.



      , , , , , ,