Mercurial > hg > monetdb-java
comparison tests/OnClientTester.java @ 525:70ff796c42f7 onclient
Run subset of tests based on prefix
author | Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com> |
---|---|
date | Thu, 26 Aug 2021 14:20:07 +0200 (2021-08-26) |
parents | 71644dc873fe |
children | 6060ca8c5c1a |
comparison
equal
deleted
inserted
replaced
524:71644dc873fe | 525:70ff796c42f7 |
---|---|
20 private Statement stmt; | 20 private Statement stmt; |
21 private StringWriter outBuffer; | 21 private StringWriter outBuffer; |
22 | 22 |
23 public static void main(String[] args) throws SQLException, NoSuchMethodException { | 23 public static void main(String[] args) throws SQLException, NoSuchMethodException { |
24 String jdbcUrl = null; | 24 String jdbcUrl = null; |
25 String specificTest = null; | 25 String requiredPrefix = null; |
26 int verbosity = 0; | 26 int verbosity = 0; |
27 | 27 |
28 for (String arg: args) { | 28 for (String arg : args) { |
29 if (arg.equals("-v")) | 29 if (arg.equals("-v")) |
30 verbosity++; | 30 verbosity++; |
31 else if (arg.equals("-vv")) | 31 else if (arg.equals("-vv")) |
32 verbosity += 2; | 32 verbosity += 2; |
33 else if (jdbcUrl == null) | 33 else if (jdbcUrl == null) |
34 jdbcUrl = arg; | 34 jdbcUrl = arg; |
35 else if (specificTest == null) | 35 else if (requiredPrefix == null) |
36 specificTest = arg; | 36 requiredPrefix = arg; |
37 else { | 37 else { |
38 System.err.println("Unexpected argument " + arg); | 38 System.err.println("Unexpected argument " + arg); |
39 System.exit(2); | 39 System.exit(2); |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 OnClientTester tester = new OnClientTester(jdbcUrl, verbosity); | 43 OnClientTester tester = new OnClientTester(jdbcUrl, verbosity); |
44 if (specificTest != null) | 44 tester.runTests(requiredPrefix); |
45 tester.runTest(specificTest); | |
46 else | |
47 tester.runTests(); | |
48 | 45 |
49 if (tester.verbosity >= VERBOSITY_ON || tester.failureCount > 0) { | 46 if (tester.verbosity >= VERBOSITY_ON || tester.failureCount > 0) { |
50 System.out.println(); | 47 System.out.println(); |
51 System.out.println("Ran " + tester.testCount + " tests, " + tester.failureCount + " failed"); | 48 System.out.println("Ran " + tester.testCount + " tests, " + tester.failureCount + " failed"); |
52 } | 49 } |
58 public OnClientTester(String jdbcUrl, int verbosity) { | 55 public OnClientTester(String jdbcUrl, int verbosity) { |
59 this.jdbcUrl = jdbcUrl; | 56 this.jdbcUrl = jdbcUrl; |
60 this.verbosity = verbosity; | 57 this.verbosity = verbosity; |
61 } | 58 } |
62 | 59 |
63 private void runTests() throws SQLException, NoSuchMethodException { | 60 private void runTests(String testPrefix) throws SQLException, NoSuchMethodException { |
64 for (Method method: this.getClass().getDeclaredMethods()) { | 61 String initialPrefix = "test_"; |
62 String methodPrefix = testPrefix == null ? initialPrefix : initialPrefix + testPrefix; | |
63 | |
64 for (Method method : this.getClass().getDeclaredMethods()) { | |
65 String methodName = method.getName(); | 65 String methodName = method.getName(); |
66 if (methodName.startsWith("test_") && method.getParameterCount() == 0) { | 66 if (methodName.startsWith(methodPrefix) && method.getParameterCount() == 0) { |
67 String testName = methodName.substring(5); | 67 String testName = methodName.substring(initialPrefix.length()); |
68 runTest(testName, method); | 68 runTest(testName, method); |
69 } | 69 } |
70 } | 70 } |
71 } | 71 } |
72 | 72 |