├── scott-gradle-plugin
├── .gitignore
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── src
│ └── main
│ │ ├── resources
│ │ └── META-INF
│ │ │ └── gradle-plugins
│ │ │ └── hu.advancedweb.scott-gradle-plugin.properties
│ │ └── java
│ │ └── hu
│ │ └── advancedweb
│ │ └── scott
│ │ ├── ScottPluginExtension.java
│ │ └── ScottPlugin.java
├── build.gradle
└── gradlew.bat
├── docs
├── architecture.png
├── scott-in-action.png
├── release_guide.md
├── architecture.xml
├── configuration.md
└── manual_setup.md
├── scott-tests
├── readme.md
├── configuration-example-classes
│ ├── src
│ │ └── main
│ │ │ └── java
│ │ │ └── hu
│ │ │ └── advancedweb
│ │ │ └── scott
│ │ │ └── examples
│ │ │ ├── AnnotationA.java
│ │ │ ├── AnnotationB.java
│ │ │ ├── ClassA.java
│ │ │ ├── otherpackage
│ │ │ └── ClassC.java
│ │ │ ├── somepackage
│ │ │ └── ClassB.java
│ │ │ ├── ClassWithUnhandledException.java
│ │ │ ├── ClassWithFeatures.java
│ │ │ ├── ClassWithTrys.java
│ │ │ ├── ClassWithVaryingMethodSizes.java
│ │ │ └── ClassWithLambdas.java
│ ├── readme.md
│ └── pom.xml
├── junit5-tests
│ ├── readme.md
│ ├── src
│ │ └── test
│ │ │ └── java
│ │ │ └── hu
│ │ │ └── advancedweb
│ │ │ └── scott
│ │ │ ├── InterfaceTest.java
│ │ │ ├── SimpleTest.java
│ │ │ ├── Java16Test.java
│ │ │ ├── InterfaceTestHelper.java
│ │ │ ├── TestInfoTest.java
│ │ │ ├── Java14Test.java
│ │ │ ├── Java11Test.java
│ │ │ ├── AssumptionsTest.java
│ │ │ ├── Java13Test.java
│ │ │ ├── helper
│ │ │ └── TestHelper.java
│ │ │ ├── AssertionsTest.java
│ │ │ └── NestedClassTest.java
│ └── pom.xml
├── junit4-tests
│ ├── readme.md
│ ├── src
│ │ └── test
│ │ │ └── java
│ │ │ └── hu
│ │ │ └── advancedweb
│ │ │ └── scott
│ │ │ ├── StaticFieldRecordingTestHelperSuperClass.java
│ │ │ ├── StaticFieldRecordingTestHelperInterface.java
│ │ │ ├── StaticFieldRecordingTestHelper.java
│ │ │ ├── ControlFlowTest.java
│ │ │ ├── RuleInjectionTest.java
│ │ │ ├── VariableStateLeakageTest.java
│ │ │ ├── MethodNameAndClassTrackingTest.java
│ │ │ ├── TryWithResourcesRecordingTest.java
│ │ │ ├── TestHelper.java
│ │ │ ├── runtime
│ │ │ └── report
│ │ │ │ ├── ScottReportTest.java
│ │ │ │ └── FailureRendererTest.java
│ │ │ ├── FieldRecordingTest.java
│ │ │ ├── RecordIncMutationTest.java
│ │ │ ├── FieldRecordingInitialValuesTest.java
│ │ │ ├── JdkLibTest.java
│ │ │ ├── LambdaRecordingTest.java
│ │ │ ├── ExceptionTest.java
│ │ │ └── StaticFieldRecordingTest.java
│ └── pom.xml
├── configuration-based-tests
│ ├── readme.md
│ ├── src
│ │ └── test
│ │ │ └── java
│ │ │ └── hu
│ │ │ └── advancedweb
│ │ │ └── scott
│ │ │ ├── helper
│ │ │ ├── ByteArrayClassLoader.java
│ │ │ ├── TestScottRuntimeVerifier.java
│ │ │ ├── ClassFileStructurePrinter.java
│ │ │ └── InstrumentedObject.java
│ │ │ ├── MultiInstrumentationTest.java
│ │ │ ├── UnhandledExceptionRecordingTest.java
│ │ │ ├── DisabledFeaturesConfigTest.java
│ │ │ ├── TryTest.java
│ │ │ ├── ReturnRecordingTest.java
│ │ │ └── AnnotationInclusionExclusionTest.java
│ └── pom.xml
└── pom.xml
├── scott-examples
├── junit4
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── src
│ │ ├── main
│ │ │ └── java
│ │ │ │ └── hu
│ │ │ │ └── advancedweb
│ │ │ │ └── example
│ │ │ │ ├── FaultyAdder.java
│ │ │ │ ├── UserService.java
│ │ │ │ ├── Counter.java
│ │ │ │ └── User.java
│ │ └── test
│ │ │ └── java
│ │ │ └── hu
│ │ │ └── advancedweb
│ │ │ └── example
│ │ │ ├── CounterTest.java
│ │ │ ├── UserTest.java
│ │ │ ├── StringTest.java
│ │ │ ├── ParameterizedTest.java
│ │ │ ├── ListTest.java
│ │ │ └── LambdaTest.java
│ ├── build.gradle
│ ├── pom.xml
│ ├── gradlew.bat
│ └── readme.md
├── junit5
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── src
│ │ └── test
│ │ │ └── java
│ │ │ └── hu
│ │ │ └── advancedweb
│ │ │ └── scott
│ │ │ ├── VarTest.java
│ │ │ ├── NestedClassTest.java
│ │ │ └── JUnit5DemoTest.java
│ ├── build.gradle
│ ├── pom.xml
│ ├── gradlew.bat
│ └── readme.md
└── cucumber-io-cucumber
│ ├── src
│ ├── main
│ │ └── java
│ │ │ └── hu
│ │ │ └── advancedweb
│ │ │ └── example
│ │ │ ├── Operation.java
│ │ │ └── Calculator.java
│ └── test
│ │ ├── resources
│ │ └── feature
│ │ │ └── calculator.feature
│ │ └── java
│ │ └── hu
│ │ └── advancedweb
│ │ └── example
│ │ ├── FeatureTest.java
│ │ └── step
│ │ └── CalculatorSteps.java
│ ├── readme.md
│ └── pom.xml
├── .gitignore
├── scott
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── META-INF
│ │ │ │ └── MANIFEST.MF
│ │ └── java
│ │ │ └── hu
│ │ │ └── advancedweb
│ │ │ └── scott
│ │ │ ├── instrumentation
│ │ │ ├── transformation
│ │ │ │ ├── Logger.java
│ │ │ │ ├── config
│ │ │ │ │ └── ClassMatcher.java
│ │ │ │ ├── LocalVariableScope.java
│ │ │ │ ├── AccessedField.java
│ │ │ │ ├── ConstructorTransformerMethodVisitor.java
│ │ │ │ ├── VariableType.java
│ │ │ │ ├── ScottClassTransformer.java
│ │ │ │ ├── StateTrackingClassVisitor.java
│ │ │ │ └── param
│ │ │ │ │ ├── DiscoveryClassVisitor.java
│ │ │ │ │ └── DiscoveryMethodVisitor.java
│ │ │ ├── ScottAgent.java
│ │ │ ├── ScottClassFileTransformer.java
│ │ │ └── ScottConfigurer.java
│ │ │ └── runtime
│ │ │ ├── report
│ │ │ ├── Snapshot.java
│ │ │ ├── javasource
│ │ │ │ ├── SourcePathResolver.java
│ │ │ │ ├── MethodBoundaryExtractor.java
│ │ │ │ └── MethodSource.java
│ │ │ └── ScottReport.java
│ │ │ ├── track
│ │ │ ├── StateData.java
│ │ │ └── ContextualData.java
│ │ │ ├── ExceptionUtil.java
│ │ │ ├── ScottJUnit5Extension.java
│ │ │ └── ScottReportingRule.java
│ └── test
│ │ └── java
│ │ └── hu
│ │ └── advancedweb
│ │ └── scott
│ │ └── instrumentation
│ │ └── transformation
│ │ ├── VariableTypeTest.java
│ │ └── config
│ │ └── ClassMatcherTest.java
└── readme.md
├── scott-maven-plugin
├── META-INF
│ └── m2e
│ │ └── lifecycle-mapping-metadata.xml
├── src
│ └── hu
│ │ └── advancedweb
│ │ └── maven
│ │ └── ScottAgentMojo.java
└── pom.xml
├── pom.xml
├── LICENSE
├── azure-pipelines.yml
└── CONTRIBUTING.md
/scott-gradle-plugin/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle/
2 | build/
3 |
--------------------------------------------------------------------------------
/docs/architecture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dodie/scott/HEAD/docs/architecture.png
--------------------------------------------------------------------------------
/docs/scott-in-action.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dodie/scott/HEAD/docs/scott-in-action.png
--------------------------------------------------------------------------------
/scott-gradle-plugin/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dodie/scott/HEAD/scott-gradle-plugin/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/scott-tests/readme.md:
--------------------------------------------------------------------------------
1 | Scott Test Reporter - Tests
2 | ===========================
3 |
4 | These projects ensure that Scott remains bug free.
5 |
6 |
--------------------------------------------------------------------------------
/scott-examples/junit4/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dodie/scott/HEAD/scott-examples/junit4/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/scott-examples/junit5/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dodie/scott/HEAD/scott-examples/junit5/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/scott-gradle-plugin/src/main/resources/META-INF/gradle-plugins/hu.advancedweb.scott-gradle-plugin.properties:
--------------------------------------------------------------------------------
1 | implementation-class=hu.advancedweb.scott.ScottPlugin
2 |
--------------------------------------------------------------------------------
/scott-tests/configuration-example-classes/src/main/java/hu/advancedweb/scott/examples/AnnotationA.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott.examples;
2 |
3 | public @interface AnnotationA {
4 |
5 | }
6 |
--------------------------------------------------------------------------------
/scott-tests/configuration-example-classes/src/main/java/hu/advancedweb/scott/examples/AnnotationB.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott.examples;
2 |
3 | public @interface AnnotationB {
4 |
5 | }
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | build/
3 | target
4 | .classpath
5 | .project
6 | .settings
7 | pom.xml.asc
8 | dependency-reduced-pom.xml
9 | out
10 | .shelf
11 | .idea
12 | *.iml
13 | *.ipr
14 | *.iws
15 |
--------------------------------------------------------------------------------
/scott-examples/cucumber-io-cucumber/src/main/java/hu/advancedweb/example/Operation.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.example;
2 |
3 | public interface Operation {
4 |
5 | int perform(int arg1, int arg2);
6 |
7 | }
--------------------------------------------------------------------------------
/scott-examples/cucumber-io-cucumber/src/test/resources/feature/calculator.feature:
--------------------------------------------------------------------------------
1 | Feature: Calculator
2 |
3 | Scenario: Addition
4 | Given a Calculator
5 | When I add 1 and 2
6 | Then the result is 4
7 |
8 |
--------------------------------------------------------------------------------
/scott/src/main/resources/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Premain-Class: hu.advancedweb.scott.instrumentation.ScottAgent
3 | Can-Redefine-Classes: true
4 | Can-Retransform-Classes: true
5 | Can-Set-Native-Method-Prefix: true
--------------------------------------------------------------------------------
/scott-tests/junit5-tests/readme.md:
--------------------------------------------------------------------------------
1 | Scott Test Reporter - JUnit 5 Test Suite
2 | ========================================
3 |
4 | Contains narrow-scoped tests to test Scott Test Reporter in integration with JUnit 5, Maven and Java 14.
5 |
6 |
--------------------------------------------------------------------------------
/scott-tests/configuration-example-classes/src/main/java/hu/advancedweb/scott/examples/ClassA.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott.examples;
2 |
3 | @AnnotationA
4 | public class ClassA {
5 |
6 | public String hello() {
7 | return "Hello";
8 | }
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/scott-gradle-plugin/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/scott-examples/junit4/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/scott-examples/junit5/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/scott-tests/junit4-tests/readme.md:
--------------------------------------------------------------------------------
1 | Scott Test Reporter - JUnit 4 Test Suite
2 | ========================================
3 |
4 | This is the core test suite for Scott, containing most of the feature tests.
5 |
6 | It tests Scott Test Reporter in integration with JUnit 4 and Java 8 in Maven build using Scott Agent.
7 |
8 |
--------------------------------------------------------------------------------
/scott-examples/junit4/src/main/java/hu/advancedweb/example/FaultyAdder.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.example;
2 |
3 | public class FaultyAdder {
4 |
5 | public static int add(int a, int b) {
6 | if (a == 2 && b == 2) {
7 | return 5; // Yuck! A bug!
8 | } else {
9 | return a + b;
10 | }
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/scott-tests/configuration-example-classes/readme.md:
--------------------------------------------------------------------------------
1 | Scott Test Reporter - Example classes for configuration based tests
2 | ===================================================================
3 |
4 | This package contains example classes that can be used during configuration based tests.
5 | See `configuration-based-tests` module.
6 |
7 |
--------------------------------------------------------------------------------
/scott/readme.md:
--------------------------------------------------------------------------------
1 | Scott Test Reporter
2 | ===================
3 |
4 | This project contains the instrumentation and runtime parts of Scott.
5 |
6 |
7 | Build
8 | -----
9 | ``` mvn install ```
10 |
11 | For a Docker-based setup, see the [development guide](https://github.com/dodie/scott/blob/master/docs/development-guide.md).
12 |
--------------------------------------------------------------------------------
/scott-tests/junit4-tests/src/test/java/hu/advancedweb/scott/StaticFieldRecordingTestHelperSuperClass.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott;
2 |
3 | public class StaticFieldRecordingTestHelperSuperClass {
4 | public static String SOME_VALUE_FROM_SUPER_TO_READ = "super";
5 | public static String SOME_VALUE_FROM_SUPER_TO_WRITE = "before_write";
6 | }
7 |
--------------------------------------------------------------------------------
/scott-tests/configuration-example-classes/src/main/java/hu/advancedweb/scott/examples/otherpackage/ClassC.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott.examples.otherpackage;
2 |
3 | import hu.advancedweb.scott.examples.AnnotationB;
4 |
5 | @AnnotationB
6 | public class ClassC {
7 |
8 | public String hello() {
9 | return "Hello";
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/scott-tests/configuration-example-classes/src/main/java/hu/advancedweb/scott/examples/somepackage/ClassB.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott.examples.somepackage;
2 |
3 | import hu.advancedweb.scott.examples.AnnotationA;
4 |
5 | @AnnotationA
6 | public class ClassB {
7 |
8 | public String hello() {
9 | return "Hello";
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/scott-tests/junit5-tests/src/test/java/hu/advancedweb/scott/InterfaceTest.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import static org.junit.jupiter.api.Assertions.assertEquals;
5 |
6 | public class InterfaceTest {
7 |
8 | @Test
9 | public void test() throws Exception {
10 | assertEquals(2, 2);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/scott-examples/junit4/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'java'
3 | id "hu.advancedweb.scott-gradle-plugin" version "4.0.1"
4 | }
5 |
6 | group 'hu.advancedweb'
7 | version '1.0-SNAPSHOT'
8 |
9 | sourceCompatibility = 1.8
10 |
11 | repositories {
12 | mavenCentral()
13 | }
14 |
15 | dependencies {
16 | testCompile group: 'junit', name: 'junit', version: '4.12'
17 | }
18 |
--------------------------------------------------------------------------------
/scott-examples/junit4/src/main/java/hu/advancedweb/example/UserService.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.example;
2 |
3 | public class UserService {
4 |
5 | private Long lastId = 41L;
6 |
7 | public User createUser(String email, String name) {
8 | User user;
9 | user = new User();
10 | user.setId(++lastId);
11 | user.setEmail(email);
12 | user.setName(name);
13 | return user;
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/scott/src/main/java/hu/advancedweb/scott/instrumentation/transformation/Logger.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott.instrumentation.transformation;
2 |
3 | class Logger {
4 |
5 | private boolean enabled;
6 |
7 | Logger(boolean enabled) {
8 | this.enabled = enabled;
9 | }
10 |
11 | void log(String message) {
12 | if (enabled) {
13 | System.out.println("Scott instrumentation: " + message);
14 | }
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/scott-maven-plugin/META-INF/m2e/lifecycle-mapping-metadata.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | prepare-agent
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/scott/src/main/java/hu/advancedweb/scott/runtime/report/Snapshot.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott.runtime.report;
2 |
3 | /**
4 | * Represents a variable name - value pair of a tracked data.
5 | *
6 | * @author David Csakvari
7 | */
8 | class Snapshot {
9 |
10 | final String name;
11 | final String value;
12 |
13 | public Snapshot(String name, String value) {
14 | this.name = name;
15 | this.value = value;
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/scott-examples/junit4/src/main/java/hu/advancedweb/example/Counter.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.example;
2 |
3 | public class Counter {
4 |
5 | int state;
6 |
7 | public int get() {
8 | return state;
9 | }
10 |
11 | public void increase() {
12 | state++;
13 | }
14 |
15 | public void decrease() {
16 | state--;
17 | }
18 |
19 | @Override
20 | public String toString() {
21 | return "Counter [state=" + state + "]";
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/scott-tests/junit4-tests/src/test/java/hu/advancedweb/scott/StaticFieldRecordingTestHelperInterface.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott;
2 |
3 | public interface StaticFieldRecordingTestHelperInterface {
4 |
5 | /*
6 | * Scott can't track constants (public static final), because they get inlined at compile time.
7 | * So we don't have any test for the following field.
8 | */
9 |
10 | public static String SOME_VALUE_FROM_INTERFACE = "interface";
11 | }
12 |
--------------------------------------------------------------------------------
/scott-examples/junit4/src/test/java/hu/advancedweb/example/CounterTest.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.example;
2 |
3 | import static org.junit.Assert.assertEquals;
4 |
5 | import org.junit.Test;
6 |
7 | public class CounterTest {
8 |
9 | @Test
10 | public void test_1() {
11 | Counter counter = new Counter();
12 |
13 | counter.increase();
14 | counter.increase();
15 |
16 | int state = counter.get();
17 |
18 | assertEquals(state, 3);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/scott-tests/junit4-tests/src/test/java/hu/advancedweb/scott/StaticFieldRecordingTestHelper.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott;
2 |
3 | public class StaticFieldRecordingTestHelper {
4 |
5 | /*
6 | * Scott can't track constants (public static final), because they get inlined at compile time.
7 | * This is the reason of the SOME_VALUE_TO_READ field not being final.
8 | */
9 |
10 | public static String SOME_VALUE_TO_READ = "42";
11 | public static String SOME_VALUE_TO_WRITE = "before_write";
12 | }
13 |
--------------------------------------------------------------------------------
/scott-tests/configuration-example-classes/src/main/java/hu/advancedweb/scott/examples/ClassWithUnhandledException.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott.examples;
2 |
3 | import java.util.function.Consumer;
4 |
5 |
6 | public class ClassWithUnhandledException {
7 |
8 | public void boom() {
9 | Consumer unsafeConsumer = (s) -> {
10 | if (s == null) {
11 | throw new RuntimeException("Something went wrong.");
12 | }
13 | s.length();
14 | };
15 | unsafeConsumer.accept(null);
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/scott-examples/junit4/src/test/java/hu/advancedweb/example/UserTest.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.example;
2 |
3 | import static org.junit.Assert.assertEquals;
4 |
5 | import org.junit.Test;
6 |
7 | public class UserTest {
8 |
9 | @Test
10 | public void test_1() {
11 | UserService service = new UserService();
12 |
13 | User john = service.createUser("john@doe", "John Doe");
14 | User jane = service.createUser("jane@doe", "Jane Doe");
15 |
16 | assertEquals(john.getId(), jane.getId());
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/scott-examples/junit5/src/test/java/hu/advancedweb/scott/VarTest.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott;
2 |
3 | import static org.junit.jupiter.api.Assertions.assertEquals;
4 |
5 | import org.junit.jupiter.api.Test;
6 |
7 | public class VarTest {
8 |
9 | @Test
10 | public void testWithMessageSupplier() {
11 | var first = "Hello";
12 | var last = "World";
13 |
14 | var concatenated = first + " " + last;
15 |
16 | assertEquals("Goodbye World", concatenated,
17 | () -> "Incorrect message.");
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/scott-tests/junit5-tests/src/test/java/hu/advancedweb/scott/SimpleTest.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott;
2 |
3 | import static hu.advancedweb.scott.helper.TestHelper.wrapped;
4 | import static org.junit.jupiter.api.Assertions.assertEquals;
5 |
6 | import org.junit.jupiter.api.Test;
7 |
8 | import hu.advancedweb.scott.helper.TestHelper;
9 |
10 | public class SimpleTest {
11 |
12 | @Test
13 | void test() {
14 | String dot = ".";
15 | assertEquals(wrapped(dot), TestHelper.getLastRecordedStateForVariable("dot"));
16 | assertEquals(".", dot);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/scott-examples/cucumber-io-cucumber/src/test/java/hu/advancedweb/example/FeatureTest.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.example;
2 |
3 | import org.junit.runner.RunWith;
4 |
5 | import io.cucumber.junit.CucumberOptions;
6 | import io.cucumber.junit.Cucumber;
7 |
8 | /**
9 | * Example configuration to include Scott report in Cucumber's output.
10 | */
11 | @RunWith(Cucumber.class)
12 | @CucumberOptions(
13 | plugin = {
14 | "hu.advancedweb.scott.runtime.ScottCucumberIoFormatter:target/mycuc.html"
15 | },
16 | features = {"src/test/resources/feature/"})
17 | public class FeatureTest {}
18 |
--------------------------------------------------------------------------------
/scott-tests/junit5-tests/src/test/java/hu/advancedweb/scott/Java16Test.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott;
2 |
3 | import static hu.advancedweb.scott.helper.TestHelper.wrapped;
4 | import static org.junit.jupiter.api.Assertions.assertEquals;
5 |
6 | import hu.advancedweb.scott.helper.TestHelper;
7 | import org.junit.jupiter.api.Test;
8 |
9 |
10 | public class Java16Test {
11 |
12 | @Test
13 | public void testWithRecord() {
14 |
15 | record X(String y) { }
16 |
17 | var x = new X("hello");
18 |
19 | var y = x.y();
20 |
21 | assertEquals(wrapped("hello"), TestHelper.getLastRecordedStateForVariable("y"));
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/scott-tests/junit4-tests/src/test/java/hu/advancedweb/scott/ControlFlowTest.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott;
2 |
3 | import static org.hamcrest.CoreMatchers.equalTo;
4 | import static org.hamcrest.MatcherAssert.assertThat;
5 |
6 | import org.junit.Test;
7 |
8 | public class ControlFlowTest {
9 |
10 | @Test
11 | public void for_test() throws Exception {
12 | for (int i = 0; i < 10; i++) {
13 | int j = i * 2;
14 | assertThat(TestHelper.getLastRecordedStateForVariable("i"), equalTo(Integer.toString(i)));
15 | assertThat(TestHelper.getLastRecordedStateForVariable("j"), equalTo(Integer.toString(j)));
16 | }
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/scott-tests/configuration-example-classes/src/main/java/hu/advancedweb/scott/examples/ClassWithFeatures.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott.examples;
2 |
3 | import java.util.function.Function;
4 |
5 | public class ClassWithFeatures {
6 |
7 | private static Integer I = 1;
8 | private static Integer i = 1;
9 |
10 | public static Integer i(int j) {
11 | return j+1;
12 | }
13 |
14 | public Integer ii() {
15 | int lo = i(4);
16 | lo++;
17 | I++;
18 | i++;
19 |
20 | Function f = (x) -> x * x;
21 |
22 | return f.apply(1 + I + i + lo + iii(2));
23 | }
24 |
25 | private int iii(int j) {
26 | return j * j;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | hu.advancedweb
7 | scott-parent
8 | 4.0.1
9 | pom
10 |
11 | Scott Test Reporter - POM
12 |
13 |
14 | scott
15 | scott-maven-plugin
16 | scott-tests
17 |
18 |
19 |
--------------------------------------------------------------------------------
/scott-examples/junit5/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'java'
3 | id "hu.advancedweb.scott-gradle-plugin" version "4.0.1"
4 | }
5 |
6 | group 'hu.advancedweb'
7 | version '1.0-SNAPSHOT'
8 |
9 | sourceCompatibility = 1.8
10 |
11 | repositories {
12 | mavenCentral()
13 | }
14 |
15 | dependencies {
16 | testCompile('org.junit.jupiter:junit-jupiter-api:5.3.1')
17 | testCompile('org.junit.jupiter:junit-jupiter-params:5.3.1')
18 | testRuntime('org.junit.jupiter:junit-jupiter-engine:5.3.1')
19 | testRuntime('org.mockito:mockito-core:2.2.28')
20 | }
21 |
22 |
23 | test {
24 | useJUnitPlatform()
25 | testLogging {
26 | events "passed", "skipped", "failed"
27 | }
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/scott-tests/junit5-tests/src/test/java/hu/advancedweb/scott/InterfaceTestHelper.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott;
2 |
3 | import org.junit.jupiter.api.AfterAll;
4 | import org.junit.jupiter.api.AfterEach;
5 | import org.junit.jupiter.api.BeforeAll;
6 | import org.junit.jupiter.api.BeforeEach;
7 | import org.junit.jupiter.api.TestInfo;
8 |
9 | public interface InterfaceTestHelper {
10 |
11 | @BeforeAll
12 | static void beforeAllTests() {
13 | }
14 |
15 | @AfterAll
16 | static void afterAllTests() {
17 | }
18 |
19 | @BeforeEach
20 | default void beforeEachTest(TestInfo testInfo) {
21 | }
22 |
23 | @AfterEach
24 | default void afterEachTest(TestInfo testInfo) {
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/scott/src/main/java/hu/advancedweb/scott/runtime/track/StateData.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott.runtime.track;
2 |
3 | public class StateData extends ContextualData {
4 |
5 | /** Name of the variable or field. */
6 | public final String name;
7 |
8 | /** Recorded value. */
9 | public final String value;
10 |
11 | public StateData(int lineNumber, String methodName, String name, String value) {
12 | super(lineNumber, methodName);
13 | this.name = name;
14 | this.value = value;
15 | }
16 |
17 | @Override
18 | public String toString() {
19 | return "StateData [lineNumber=" + lineNumber + ", methodName=" + methodName + ", name=" + name + ", value=" + value + "]";
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/scott-tests/configuration-based-tests/readme.md:
--------------------------------------------------------------------------------
1 | Scott Test Reporter - Configuration based tests
2 | ===============================================
3 |
4 | This test suite excersizes Scott via its Java API by dynamically loading
5 | class files and transforming them on the fly with different configuration.
6 |
7 | This module also excersizes behavior not used directly by the Scott Test Reporter,
8 | for example excluding short methods from the instrumentation.
9 |
10 | It uses class files from the `configuration-example-classes` module by file path based lookup
11 | rather than an ususal classpath based dependency. If the example classes were on the
12 | classpath the test mechanism could not load them dynamically.
13 |
--------------------------------------------------------------------------------
/scott/src/test/java/hu/advancedweb/scott/instrumentation/transformation/VariableTypeTest.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott.instrumentation.transformation;
2 |
3 | import static org.junit.Assert.assertEquals;
4 |
5 | import org.junit.Test;
6 |
7 | public class VariableTypeTest {
8 |
9 | @Test
10 | public void test() {
11 | assertEquals(VariableType.INTEGER, VariableType.getReturnTypeFromMethodDesc("()I"));
12 | assertEquals(VariableType.REFERENCE, VariableType.getReturnTypeFromMethodDesc("()Ljava/lang/String"));
13 | assertEquals(VariableType.VOID, VariableType.getReturnTypeFromMethodDesc("()V"));
14 | assertEquals(VariableType.DOUBLE, VariableType.getReturnTypeFromMethodDesc("(I)D"));
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/scott-tests/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | hu.advancedweb
7 | scott-tests
8 | pom
9 | 4.0.1
10 |
11 | Scott Test Reporter - Tests
12 |
13 |
14 | junit4-tests
15 | junit5-tests
16 | configuration-example-classes
17 | configuration-based-tests
18 |
19 |
20 |
--------------------------------------------------------------------------------
/scott-tests/configuration-based-tests/src/test/java/hu/advancedweb/scott/helper/ByteArrayClassLoader.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott.helper;
2 |
3 | import java.util.Map;
4 |
5 | public class ByteArrayClassLoader extends ClassLoader {
6 |
7 | private Map classBytecodes;
8 |
9 | public ByteArrayClassLoader(ClassLoader parent, Map classBytecodes) {
10 | super(parent);
11 | this.classBytecodes = classBytecodes;
12 | }
13 |
14 | @Override
15 | public Class> findClass(String name) {
16 | if (!classBytecodes.containsKey(name)) {
17 | throw new RuntimeException("Class not found: " + name);
18 | }
19 | byte[] bytes = classBytecodes.get(name);
20 | return defineClass(name, bytes, 0, bytes.length);
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/scott/src/main/java/hu/advancedweb/scott/runtime/track/ContextualData.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott.runtime.track;
2 |
3 | /**
4 | * Represents a data point collected at a given line number.
5 | *
6 | * @author David Csakvari
7 | */
8 | public class ContextualData {
9 |
10 | /** Line number where the data is collected. */
11 | public final int lineNumber;
12 |
13 | /** Method where the data is collected. */
14 | public final String methodName;
15 |
16 | public ContextualData(int lineNumber, String methodName) {
17 | this.lineNumber = lineNumber;
18 | this.methodName = methodName;
19 | }
20 |
21 | @Override
22 | public String toString() {
23 | return "ContextualData [lineNumber=" + lineNumber + ", methodName=" + methodName + "]";
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/scott-examples/junit4/src/main/java/hu/advancedweb/example/User.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.example;
2 |
3 | public class User {
4 |
5 | private Long id;
6 |
7 | private String email;
8 |
9 | private String name;
10 |
11 | public Long getId() {
12 | return id;
13 | }
14 |
15 | public void setId(Long id) {
16 | this.id = id;
17 | }
18 |
19 | public String getEmail() {
20 | return email;
21 | }
22 |
23 | public void setEmail(String email) {
24 | this.email = email;
25 | }
26 |
27 | public String getFirstName() {
28 | return name;
29 | }
30 |
31 | public void setName(String name) {
32 | this.name = name;
33 | }
34 |
35 | @Override
36 | public String toString() {
37 | return "User [id=" + id + ", email=" + email + ", name=" + name + "]";
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/scott-tests/configuration-example-classes/src/main/java/hu/advancedweb/scott/examples/ClassWithTrys.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott.examples;
2 |
3 | import java.io.ByteArrayOutputStream;
4 | import java.io.IOException;
5 | import java.io.PrintStream;
6 |
7 | public class ClassWithTrys {
8 |
9 | public boolean hello() {
10 | try {
11 | if (this.getClass().getName().isEmpty()) {
12 | return false;
13 | }
14 |
15 | String string = "a";
16 | return true;
17 | } finally {
18 | System.out.println("Hey");
19 | }
20 | }
21 |
22 | public void hello2() throws IOException {
23 | try (ByteArrayOutputStream out = new ByteArrayOutputStream();
24 | PrintStream printStream = new PrintStream(out)) {
25 |
26 | printStream.append("Hello World");
27 | }
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/scott-tests/junit4-tests/src/test/java/hu/advancedweb/scott/RuleInjectionTest.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott;
2 |
3 | import static org.hamcrest.CoreMatchers.notNullValue;
4 | import static org.hamcrest.MatcherAssert.assertThat;
5 | import static org.junit.Assert.assertTrue;
6 |
7 | import java.lang.annotation.Annotation;
8 | import java.lang.reflect.Field;
9 |
10 | import org.junit.Test;
11 |
12 | public class RuleInjectionTest {
13 |
14 | @Test
15 | public void ruleInjected() throws Exception {
16 | Field field = this.getClass().getDeclaredField("scottReportingRule");
17 |
18 | Annotation[] annotations = field.getDeclaredAnnotations();
19 | Object value = field.get(this);
20 |
21 | assertThat(value, notNullValue());
22 | assertTrue(annotations.length != 0);
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/scott-tests/junit5-tests/src/test/java/hu/advancedweb/scott/TestInfoTest.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott;
2 |
3 | import static org.junit.jupiter.api.Assertions.assertEquals;
4 | import static org.junit.jupiter.api.Assertions.assertTrue;
5 |
6 | import org.junit.jupiter.api.DisplayName;
7 | import org.junit.jupiter.api.Tag;
8 | import org.junit.jupiter.api.Test;
9 | import org.junit.jupiter.api.TestInfo;
10 |
11 | import hu.advancedweb.scott.helper.TestHelper;
12 |
13 | public class TestInfoTest {
14 |
15 | @Test
16 | @DisplayName("TEST 1")
17 | @Tag("my-tag")
18 | void test1(TestInfo testInfo) {
19 | assertEquals("TEST 1", testInfo.getDisplayName());
20 | assertTrue(testInfo.getTags().contains("my-tag"));
21 | assertTrue(TestHelper.getLastRecordedStateForVariable("testInfo") != null);
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/scott/src/main/java/hu/advancedweb/scott/runtime/ExceptionUtil.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott.runtime;
2 |
3 | import java.lang.reflect.Field;
4 |
5 | class ExceptionUtil {
6 |
7 | private ExceptionUtil() {
8 | // Utility class, use static methods.
9 | }
10 |
11 | static void setExceptionMessage(Object object, Object fieldValue) {
12 | final String fieldName = "detailMessage";
13 | Class> clazz = object.getClass();
14 | while (clazz != null) {
15 | try {
16 | Field field = clazz.getDeclaredField(fieldName);
17 | field.setAccessible(true);
18 | field.set(object, fieldValue);
19 | return;
20 | } catch (NoSuchFieldException e) {
21 | clazz = clazz.getSuperclass();
22 | } catch (Exception e) {
23 | throw new IllegalStateException(e);
24 | }
25 | }
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/scott-tests/junit5-tests/src/test/java/hu/advancedweb/scott/Java14Test.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott;
2 |
3 | import static hu.advancedweb.scott.helper.TestHelper.wrapped;
4 | import static org.junit.jupiter.api.Assertions.assertEquals;
5 |
6 | import hu.advancedweb.scott.helper.TestHelper;
7 | import org.junit.jupiter.api.Test;
8 |
9 |
10 | public class Java14Test {
11 |
12 | @Test
13 | public void testWithTextBlock() {
14 | Object o = "hello";
15 |
16 | final String result;
17 | if (o instanceof String s) {
18 | result = s + " world";
19 | } else {
20 | result = "not a string";
21 | }
22 |
23 | assertEquals(wrapped("hello"), TestHelper.getLastRecordedStateForVariable("o"));
24 | assertEquals(wrapped("hello"), TestHelper.getLastRecordedStateForVariable("s"));
25 | assertEquals("hello world", result);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/scott-tests/junit4-tests/src/test/java/hu/advancedweb/scott/VariableStateLeakageTest.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott;
2 |
3 | import static org.junit.Assert.assertTrue;
4 |
5 | import org.junit.FixMethodOrder;
6 | import org.junit.Test;
7 | import org.junit.runners.MethodSorters;
8 |
9 | import hu.advancedweb.scott.runtime.track.StateRegistry;
10 |
11 | @FixMethodOrder(MethodSorters.NAME_ASCENDING)
12 | public class VariableStateLeakageTest {
13 |
14 | @Test
15 | public void step_1_run_a_test_and_check_that_scott_recorded_something() throws Exception {
16 | int i = 5;
17 | i = i + 2;
18 | assertTrue(!StateRegistry.getLocalVariableStates().isEmpty());
19 | }
20 |
21 | @Test
22 | public void step_2_check_that_the_recorded_variable_states_are_cleared_for_the_next_test() throws Exception {
23 | assertTrue(StateRegistry.getLocalVariableStates().isEmpty());
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/scott-tests/junit4-tests/src/test/java/hu/advancedweb/scott/MethodNameAndClassTrackingTest.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott;
2 |
3 | import static org.hamcrest.CoreMatchers.equalTo;
4 | import static org.hamcrest.MatcherAssert.assertThat;
5 |
6 | import org.junit.Test;
7 |
8 | import hu.advancedweb.scott.runtime.track.StateRegistry;
9 |
10 | public class MethodNameAndClassTrackingTest {
11 |
12 | @Test
13 | public void test1() throws Exception {
14 | assertThat(StateRegistry.getTestClassType(), equalTo("hu/advancedweb/scott/MethodNameAndClassTrackingTest"));
15 | assertThat(StateRegistry.getTestMethodName(), equalTo("test1"));
16 | }
17 |
18 | @Test
19 | public void test2() throws Exception {
20 | assertThat(StateRegistry.getTestClassType(), equalTo("hu/advancedweb/scott/MethodNameAndClassTrackingTest"));
21 | assertThat(StateRegistry.getTestMethodName(), equalTo("test2"));
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/scott-examples/junit5/src/test/java/hu/advancedweb/scott/NestedClassTest.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott;
2 |
3 | import static org.junit.jupiter.api.Assertions.assertEquals;
4 |
5 | import org.junit.jupiter.api.BeforeEach;
6 | import org.junit.jupiter.api.Nested;
7 | import org.junit.jupiter.api.Test;
8 |
9 |
10 | public class NestedClassTest {
11 |
12 | String value;
13 |
14 | @BeforeEach
15 | void reset() {
16 | value = "1";
17 | }
18 |
19 | @Test
20 | void test() {
21 | String dot = ".";
22 | value += dot;
23 | assertEquals("1", value);
24 | }
25 |
26 | @Nested
27 | class NestedClass {
28 |
29 | String nestedValue = "a";
30 |
31 | @BeforeEach
32 | void reset() {
33 | value = value + "2";
34 | }
35 |
36 | @Test
37 | void test() {
38 | String dot = ".";
39 | nestedValue += dot;
40 | value += dot + nestedValue;
41 |
42 | assertEquals("12.a", value);
43 | }
44 |
45 | }
46 | }
--------------------------------------------------------------------------------
/scott-examples/junit4/src/test/java/hu/advancedweb/example/StringTest.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.example;
2 |
3 | import static org.junit.Assert.assertEquals;
4 |
5 | import org.junit.Test;
6 |
7 | public class StringTest {
8 |
9 | @Test
10 | public void test_1() {
11 | String first = "Hello";
12 | String last = "World";
13 |
14 | String concatenated = first + " " + last;
15 |
16 | assertEquals("Goodbye World", concatenated);
17 | }
18 |
19 | @Test
20 | public void test_2() {
21 | String hello = "Hello World";
22 |
23 | int indexOfSpace = hello.indexOf(" ");
24 | String lastPart = hello.substring(indexOfSpace);
25 |
26 | assertEquals("World", lastPart);
27 | }
28 |
29 | @Test
30 | public void test_3() {
31 | String empty = "";
32 | String first = "1";
33 | String last = "2";
34 |
35 | String concatenated = empty + first + last;
36 |
37 | assertEquals(12, concatenated);
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/scott-tests/configuration-example-classes/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | hu.advancedweb
5 | configuration-example-classes
6 | 4.0.1
7 |
8 | UTF-8
9 |
10 | Scott Test Reporter - Exampe classes for configuration-based tests
11 |
12 |
13 |
14 |
15 | org.apache.maven.plugins
16 | maven-compiler-plugin
17 | 3.8.1
18 |
19 | 1.8
20 | 1.8
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/scott-tests/junit5-tests/src/test/java/hu/advancedweb/scott/Java11Test.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott;
2 |
3 | import static hu.advancedweb.scott.helper.TestHelper.wrapped;
4 | import static org.junit.jupiter.api.Assertions.assertEquals;
5 |
6 | import hu.advancedweb.scott.helper.TestHelper;
7 | import org.junit.jupiter.api.Test;
8 | import java.util.function.Function;
9 |
10 |
11 | public class Java11Test {
12 |
13 | @Test
14 | void varTest() {
15 | var dot = ".";
16 | assertEquals(wrapped(dot), TestHelper.getLastRecordedStateForVariable("dot"));
17 | assertEquals(".", dot);
18 | }
19 |
20 | @Test
21 | public void lambdaVarTest() throws Exception {
22 | Function lambda = (var a) -> {
23 | assertEquals(wrapped(a), TestHelper.getLastRecordedStateForVariable("a"));
24 | return a;
25 | };
26 | String result = lambda.apply("1");
27 | assertEquals(wrapped(result), TestHelper.getLastRecordedStateForVariable("result"));
28 | }
29 |
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/scott-examples/cucumber-io-cucumber/src/test/java/hu/advancedweb/example/step/CalculatorSteps.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.example.step;
2 |
3 | import static org.hamcrest.Matchers.equalTo;
4 | import static org.hamcrest.MatcherAssert.assertThat;
5 |
6 | import io.cucumber.java.en.Given;
7 | import io.cucumber.java.en.Then;
8 | import io.cucumber.java.en.When;
9 | import hu.advancedweb.example.Calculator;
10 |
11 | public class CalculatorSteps {
12 |
13 | public static Calculator calculator;
14 |
15 | @Given("^a Calculator")
16 | public void a_calculator() {
17 | calculator = new Calculator();
18 | }
19 |
20 | @When("^I add (\\d+) and (\\d+)$")
21 | public void i_add_two_numbers(String arg1, String arg2) {
22 | calculator.push(arg1);
23 | calculator.push(arg2);
24 | calculator.push("+");
25 | }
26 |
27 | @Then("^the result is (\\d+)$")
28 | public void the_result_is(String expected) {
29 | String result = calculator.evaluate();
30 | assertThat(result, equalTo(expected));
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/scott-tests/configuration-example-classes/src/main/java/hu/advancedweb/scott/examples/ClassWithVaryingMethodSizes.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott.examples;
2 |
3 | /**
4 | * Note that this file is sensitive to formatting.
5 | *
6 | * @author David Csakvari
7 | */
8 | public class ClassWithVaryingMethodSizes {
9 |
10 | public String methodWith1LineBodyInlineDeclaration() { return "Hello from methodWith1LineBodyInlineDeclaration"; }
11 |
12 | public String methodWith1LineBody() {
13 | return "Hello from methodWith1LineBody";
14 | }
15 |
16 | public String methodWith3LineBody() {
17 | StringBuilder sb = new StringBuilder();
18 | sb.append("Hello from mediumMethod");
19 | return sb.toString();
20 | }
21 |
22 | public String methodWith9LineBody() {
23 | StringBuilder sb = new StringBuilder();
24 | sb.append("H");
25 | sb.append("e");
26 | sb.append("l");
27 | sb.append("l");
28 | sb.append("o");
29 | sb.append(" ");
30 | sb.append("from longMethod");
31 | return sb.toString();
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/scott-examples/cucumber-io-cucumber/src/main/java/hu/advancedweb/example/Calculator.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.example;
2 |
3 | import java.util.Deque;
4 | import java.util.LinkedList;
5 |
6 | public class Calculator {
7 |
8 | private final Deque stack = new LinkedList();
9 |
10 | public void push(String arg) {
11 | stack.add(arg);
12 | }
13 |
14 | public String evaluate() {
15 |
16 | String op = stack.removeLast();
17 | Integer x = Integer.parseInt(stack.removeLast());
18 | Integer y = Integer.parseInt(stack.removeLast());
19 |
20 | Integer val;
21 | if (op.equals("-")) {
22 | val = x - y;
23 | } else if (op.equals("+")) {
24 | val = x + y;
25 | } else if (op.equals("*")) {
26 | val = x * y;
27 | } else if (op.equals("/")) {
28 | val = x / y;
29 | } else {
30 | throw new IllegalArgumentException();
31 | }
32 |
33 | stack.push(Integer.toString(val));
34 |
35 | return stack.getLast();
36 | }
37 |
38 | @Override
39 | public String toString() {
40 | return "[stack=" + stack + "]";
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/scott-tests/configuration-based-tests/src/test/java/hu/advancedweb/scott/helper/TestScottRuntimeVerifier.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.scott.helper;
2 |
3 | public interface TestScottRuntimeVerifier {
4 |
5 | public void trackMethodStart(int lineNumber, String methodName, Class> clazz);
6 |
7 | public void trackEndOfArgumentsAtMethodStart(int lineNumber, String methodName, Class> clazz);
8 |
9 | public void trackLocalVariableState(Object value, String name, int lineNumber, String methodName, Class> clazz);
10 |
11 | public void trackUnhandledException(Throwable throwable, int lineNumber, String methodName, Class> clazz);
12 |
13 | public void trackReturn(int lineNumber, String methodName, Class> clazz);
14 |
15 | public void trackReturn(Object value, int lineNumber, String methodName, Class> clazz);
16 |
17 | public void trackLambdaDefinition(int lineNumber, String methodName, Class> clazz);
18 |
19 | public void trackFieldState(Object value, String name, int lineNumber, String methodName, Class> clazz, boolean isStatic, String owner);
20 |
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 David Csakvari
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/scott-examples/junit4/src/test/java/hu/advancedweb/example/ParameterizedTest.java:
--------------------------------------------------------------------------------
1 | package hu.advancedweb.example;
2 |
3 | import static org.hamcrest.CoreMatchers.equalTo;
4 | import static org.hamcrest.MatcherAssert.assertThat;
5 |
6 | import java.util.Arrays;
7 | import java.util.Collection;
8 |
9 | import org.junit.Test;
10 | import org.junit.runner.RunWith;
11 | import org.junit.runners.Parameterized;
12 | import org.junit.runners.Parameterized.Parameters;
13 |
14 | @RunWith(Parameterized.class)
15 | public class ParameterizedTest {
16 |
17 | @Parameters
18 | public static Collection