Test Oriented Languages: Is it Time for a New Era?

Writing tests has, sensibly, become a big part of writing software. Compilers provide a level of type, syntactic and semantic checks.

The compiler could do more though if the language included syntactic elements for state based assertions, so long as they could be compartmentalised to small, verifiable units.

This paper suggests using static analysis, in a post compilation phase, to validate declarative assertions that are built into the language syntax either through extensions or existing utilities such as annotations.  This makes assertions terser, easier to read and allows their execution in statically isolated units. Execution time is minimised due to the short scope of the test and automated stubbing (in what are denoted Seams).

Using Java as an example, this paper looks to turn something like this:

@Test
public shouldBuildFoundationsWithBricksAndCement(){
    Digger digger = mock(Digger.class);
    CementMixer mixer = mock(CementMixer.class);
    Foreman foreman = mock(Foreman.class);
    Cement cement = mock(Cement.class);
    BrickLayer layer = mock(BrickLayer.class);
    Foundation foundation = mock(Foundation.class);

    when(mixer.mix()).thenReturn(cement);
    when(digger.dig()).thenReturn(foundation);       
    when(cement.isSolid()).thenReturn(Boolean.FALSE);
    when(foreman.getLayer()).thenReturn(layer);

    ConstructionSite site = new ConstructionSite(digger, mixer, foreman);
    assertTrue(site.buildFoundation(new Bricks(101)))
}

into something like this:

shouldBuildFoundationsWithBricksAndCement(){
    Seam: 
        cement.isSolid() returns false; 
        bricks.size returns 100; 

    AssertTrue: 
        new ConstructionSite().buildFoundation(..); 
}

OR

 @Test (bricks.size = 100 ,assert = "buildFoundation false")
 @Test (bricks.size = 5, assert = "buildFoundation true")
 @Test (bricks.size = 100, cement.isSolid true @Assert: buildFoundation false)
 boolean buildFoundation(Bricks bricks){
     Cement cement = mixer.mix();
     Foundation foundation = digger.dig();
     BrickLayer layer = foreman.getLayer();
     if(!cement.isSolid() && bricks.size()> 100){
         Posts posts = layer.lay(bricks, cement);
         foundation.fill(posts);
         return true;
     }
     return false;
 }

Full paper can be found here:  IEEE, PDF

The paper was presented at the IEEE International Conference on Software Testing, Verification and Validation (ICST) in Berlin 2011.

Posted on February 2nd, 2011 in Talks, TDD


  1. Transfer 41 045 US dollars. Gо tо withdrаwаl >>> https://forms.yandex.com/cloud/65db119102848fe3bdc15a6a?hs=e0d1aea104e3483f8b132cc897f8af5b& February 28th, 2024
    21:28 GMT

    uc91u1

Have your say

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>




Safari hates me
IMPORTANT! To be able to proceed, you need to solve the following simple problem (so we know that you are a human) :-)

Add the numbers ( 6 + 7 ) and SUBTRACT two ?
Please leave these two fields as-is:

Talks (View on YouTube)