1.1 --- a/rt/vmtest/src/main/java/org/apidesign/bck2brwsr/vmtest/VMTest.java Sun Apr 28 22:15:00 2013 +0200
1.2 +++ b/rt/vmtest/src/main/java/org/apidesign/bck2brwsr/vmtest/VMTest.java Sun Apr 28 22:38:29 2013 +0200
1.3 @@ -17,6 +17,9 @@
1.4 */
1.5 package org.apidesign.bck2brwsr.vmtest;
1.6
1.7 +import java.util.ArrayList;
1.8 +import java.util.Arrays;
1.9 +import java.util.List;
1.10 import org.apidesign.bck2brwsr.launcher.Launcher;
1.11 import org.apidesign.bck2brwsr.vmtest.impl.CompareCase;
1.12 import org.testng.annotations.Factory;
1.13 @@ -34,6 +37,9 @@
1.14 * @author Jaroslav Tulach <jtulach@netbeans.org>
1.15 */
1.16 public final class VMTest {
1.17 + private final List<Class> classes = new ArrayList<>();
1.18 + private final List<String> launcher = new ArrayList<>();
1.19 +
1.20 private VMTest() {
1.21 }
1.22
1.23 @@ -50,7 +56,63 @@
1.24 * @param clazz the class (or classes) to inspect
1.25 * @return the set of created tests
1.26 */
1.27 - public static Object[] create(Class... clazz) {
1.28 - return CompareCase.create(clazz);
1.29 + public static Object[] create(Class clazz) {
1.30 + return newTests().addClass(clazz).build();
1.31 + }
1.32 +
1.33 + /** Creates new builder for test execution. Continue with methods
1.34 + * like {@link #addClass(java.lang.Class[])} or {@link #addLauncher(java.lang.String[])}.
1.35 + * Finish the process by calling {@link #build()}.
1.36 + *
1.37 + * @return new instance of a builder
1.38 + * @since 0.7
1.39 + */
1.40 + public static VMTest newTests() {
1.41 + return new VMTest();
1.42 + }
1.43 +
1.44 + /** Adds class (or classes) to the test execution. The classes are inspected
1.45 + * to contain methods annotated by
1.46 + * {@link Compare} or {@link BrwsrTest}. Appropriate set of TestNG test
1.47 + * cases is then created.
1.48 + * <p>
1.49 + * Each {@link Compare} instance runs the test in different virtual
1.50 + * machine and at the end they compare the results.
1.51 + * <p>
1.52 + * Each {@link BrwsrTest} annotated method is executed once in {@link Launcher started
1.53 + * browser}.
1.54 + *
1.55 + * @param classes one or more classes to inspect
1.56 + * @since 0.7
1.57 + */
1.58 + public final VMTest addClass(Class... classes) {
1.59 + this.classes.addAll(Arrays.asList(classes));
1.60 + return this;
1.61 + }
1.62 +
1.63 + /** Adds list of launchers that should be used to execute tests defined
1.64 + * by {@link Compare} and {@link BrwsrTest} annotations. This value
1.65 + * can be overrided by using <code>vmtest.brwsrs</code> property.
1.66 + * List of supported launchers is available in the documentation of
1.67 + * {@link Launcher}.
1.68 + *
1.69 + * @param launcher names of one or more launchers to use for the execution
1.70 + * of tests
1.71 + * @since 0.7
1.72 + */
1.73 + public final VMTest addLauncher(String... launcher) {
1.74 + this.launcher.addAll(Arrays.asList(launcher));
1.75 + return this;
1.76 + }
1.77 +
1.78 + /** Assembles the provided information into the final array of tests.
1.79 + * @return array of TestNG tests
1.80 + * @since 0.7
1.81 + */
1.82 + public final Object[] build() {
1.83 + return CompareCase.create(
1.84 + launcher.toArray(new String[0]),
1.85 + classes.toArray(new Class[0])
1.86 + );
1.87 }
1.88 }
2.1 --- a/rt/vmtest/src/main/java/org/apidesign/bck2brwsr/vmtest/impl/CompareCase.java Sun Apr 28 22:15:00 2013 +0200
2.2 +++ b/rt/vmtest/src/main/java/org/apidesign/bck2brwsr/vmtest/impl/CompareCase.java Sun Apr 28 22:38:29 2013 +0200
2.3 @@ -53,19 +53,16 @@
2.4 * @param clazz the class to inspect
2.5 * @return the set of created tests
2.6 */
2.7 - public static Object[] create(Class... classes) {
2.8 + public static Object[] create(String[] brwsr, Class[] classes) {
2.9 List<Object> ret = new ArrayList<>();
2.10
2.11 final LaunchSetup l = LaunchSetup.INSTANCE;
2.12 ret.add(l);
2.13
2.14 - String[] brwsr;
2.15 {
2.16 String p = System.getProperty("vmtest.brwsrs");
2.17 if (p != null) {
2.18 brwsr = p.split(",");
2.19 - } else {
2.20 - brwsr = new String[0];
2.21 }
2.22 }
2.23