package com.github.havarunner.scenarios.duplicated;

import org.junit.Test;

import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

import static org.junit.Assert.assertTrue;

abstract class VerifyThatTestAreRunOnlyOnceTestSuperClass {
    protected final AtomicInteger suiteObject;
    protected final List<String> scenarios;
    VerifyThatTestAreRunOnlyOnceTestSuperClass(AtomicInteger suiteObject, List<String> scenarios) {
        this.suiteObject = suiteObject;
        this.scenarios = scenarios;
    }
    @Test
    public void verifyTestIsRanOnlyOncePerScenario() {
        final int runNumber = suiteObject.addAndGet(1);
        System.out.println("Run: "+runNumber+ " for scenario: "+scenarios);
        synchronized (VerifyThatTestAreRunOnlyOnceTestOneImpl.class) {
            assertTrue(runNumber+" / "+VerifyThatTestAreRunOnlyOnceTestOneImpl.scenarios().size()+ " currentScenario: "+scenarios, VerifyThatTestAreRunOnlyOnceTestOneImpl.scenarios().size() >= runNumber);
        }
    }
}

@@ -46,16 +46,66 @@
 cated;%0A%0A
+import com.github.havarunner.annotation.AfterAll;%0A
 import o
@@ -119,16 +119,16 @@
 t.Test;%0A
-
 %0Aimport 
@@ -236,16 +236,60 @@
 ertTrue;
+%0Aimport static org.junit.Assume.assumeFalse;
 %0A%0Aabstra
@@ -429,24 +429,408 @@
  scenarios;%0A
+    /**%0A     * When HavaRunner tests are executed via SBT, both VerifyThatTestAreRunOnlyOnceSuiteImpl and VerifyThatTestAreRunOnlyOnceTestOneImpl are executed,%0A     * resulting in tests running twice, thus failing the java8 assertions here..%0A     *%0A     * This flag avoids that by making sure that we only run our suite once.%0A     */%0A    protected static boolean hasExecuted = false;%0A
     VerifyTh
@@ -1060,24 +1060,25 @@
 cenario() %7B%0A
+%0A
         fina
@@ -1264,24 +1264,62 @@
 pl.class) %7B%0A
+            assumeFalse(hasExecuted);%0A
             
@@ -1511,16 +1511,16 @@
 umber);%0A
-
         
@@ -1527,10 +1527,93 @@
 %7D%0A    %7D%0A
+    @AfterAll%0A    public void markAsExecuted() %7B%0A        hasExecuted = true;%0A    %7D%0A
 %7D%0A

Add state to VerifyThatTestAreRunOnlyOnceTestSuperClass to avoid false failures when running via sbt.