Documentation

Documentation

Get Started

To use VMLens with maven, configure a plugin tag to tell maven that the VMLens plugin should be executed at the test phase. And include com.vmlens.api as test dependency.

<project>
<!-- to include the class AllInterleaving into the test class path.  -->	
<dependency>
  <groupId>com.vmlens</groupId>
  <artifactId>api</artifactId>
  <version>1.2.2</version>
  <scope>test</scope>
</dependency>	
	
<build>
  <plugins>
<!-- to run the vmlens maven plugin during the maven test phase  -->	 
    <plugin>
        <groupId>com.vmlens</groupId>
        <artifactId>vmlens-maven-plugin</artifactId>
		<version>1.2.2</version>
        <executions>
            <execution>
                <id>test</id>
                <goals>
                    <goal>test</goal>
                </goals>
            </execution>
        </executions>
	</plugin>
     ...
    </plugins>
</build>
      ...
</project>

Then surround your test with a while loop iterating over all thread interleavings:

import com.vmlens.api.AllInterleavings;
public class TestNonVolatileField {

    @Test
    public void testUpdate() throws InterruptedException {
        try(AllInterleavings allInterleaving = new AllInterleavings("[Name of your test]")) {
            while (allInterleaving.hasNext()) {
               // place your multi-threaded test here
            }
        }
    }
}