rsocket / rsocket-java

Java implementation of RSocket
http://rsocket.io
Apache License 2.0
2.36k stars 354 forks source link

Refactor TCK test runner #297

Closed yschimke closed 7 years ago

yschimke commented 7 years ago

Implement a junit test runner that generates tests at runtime such that right click in Intellij "Run All Tests" will run the TCK tests in IDE, and "./gradlew test" will run tests also.

Junit 4 https://stackoverflow.com/a/7404732/1542667 Junit 5 https://dzone.com/articles/junit-5-dynamic-tests-generate-tests-at-run-time

yschimke commented 7 years ago

The goal here is to have them run as part of the normal development flow whether a developer uses an IDE or the command line.

yschimke commented 7 years ago

This is an example parameterized test

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;

import static org.junit.Assert.assertEquals;

@RunWith(Parameterized.class)
public class TestX {
    private File file;

    public TestX(File file) {
        this.file = file;
    }

    @Test
    public void test1() throws Exception {
        assertEquals("path1", this.file.getName());
    }

    @Parameterized.Parameters
    public static Collection<Object[]> data() {
        // load the files as you want
        Object[] fileArg1 = new Object[]{new File("path1")};
        Object[] fileArg2 = new Object[]{new File("path2")};

        Collection<Object[]> data = new ArrayList<Object[]>();
        data.add(fileArg1);
        data.add(fileArg2);
        return data;
    }
}
yschimke commented 7 years ago

https://github.com/rsocket/rsocket-java/pull/347