How to use run method of org.testng.TestRunner class

Best Testng code snippet using org.testng.TestRunner.run

Source:VerifyTests.java Github

copy

Full Screen

...17 Verify.verifyEquals("test#", "test4", "test4 doesn't match"); // fail (continue)18 Verify.verifyEquals("test5", "test5", "test5 doesn't match"); // pass19 Verify.verifyEquals("test6", "test6", "test6 doesn't match"); // pass20 Assert.assertEquals("test$", "test7", "test7 doesn't match"); // fail (exit) 21 Assert.assertEquals("test8", "test8", "test8 doesn't match"); // not run!22 Verify.verifyEquals("test9", "test9", "test9 doesn't match"); // not run!23 24 // Output25 26/* FAILED: test0127 java.lang.Throwable: Multiple failures (3)28 (1)org.muthu.VerificationError:test2 doesn't matches expected [test2] but found [test!]29 (2)org.muthu.VerificationError:test4 doesn't matches expected [test4] but found [test#]30 (3)java.lang.AssertionError:test7 doesn't matches expected [test7] but found [test$]31 Failure 1 of 332 org.muthu.VerificationError: test2 doesn't matches expected [test2] but found [test!]33 at org.testng.Assert.fail(Assert.java:94)34 at org.testng.Assert.failNotEquals(Assert.java:494)35 at org.testng.Assert.assertEquals(Assert.java:123)36 at org.testng.Assert.assertEquals(Assert.java:176)37 at org.muthu.Verify.verifyEquals(Verify.java:90)38 at org.muthu.TestVerify.test01(TestVerify.java:15)39 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)40 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)41 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)42 at java.lang.reflect.Method.invoke(Unknown Source)43 at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)44 at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)45 at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)46 at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)47 at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)48 at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)49 at org.testng.TestRunner.privateRun(TestRunner.java:767)50 at org.testng.TestRunner.run(TestRunner.java:617)51 at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)52 at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)53 at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)54 at org.testng.SuiteRunner.run(SuiteRunner.java:240)55 at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)56 at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)57 at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)58 at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)59 at org.testng.TestNG.run(TestNG.java:1057)60 at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)61 at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)62 at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)63 Failure 2 of 364 org.muthu.VerificationError: test4 doesn't matches expected [test4] but found [test#]65 at org.testng.Assert.fail(Assert.java:94)66 at org.testng.Assert.failNotEquals(Assert.java:494)67 at org.testng.Assert.assertEquals(Assert.java:123)68 at org.testng.Assert.assertEquals(Assert.java:176)69 at org.muthu.Verify.verifyEquals(Verify.java:90)70 at org.muthu.TestVerify.test01(TestVerify.java:17)71 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)72 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)73 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)74 at java.lang.reflect.Method.invoke(Unknown Source)75 at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)76 at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)77 at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)78 at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)79 at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)80 at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)81 at org.testng.TestRunner.privateRun(TestRunner.java:767)82 at org.testng.TestRunner.run(TestRunner.java:617)83 at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)84 at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)85 at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)86 at org.testng.SuiteRunner.run(SuiteRunner.java:240)87 at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)88 at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)89 at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)90 at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)91 at org.testng.TestNG.run(TestNG.java:1057)92 at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)93 at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)94 at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)95 Failure 3 of 396 java.lang.AssertionError: test7 doesn't matches expected [test7] but found [test$]97 at org.testng.Assert.fail(Assert.java:94)98 at org.testng.Assert.failNotEquals(Assert.java:494)99 at org.testng.Assert.assertEquals(Assert.java:123)100 at org.testng.Assert.assertEquals(Assert.java:176)101 at org.muthu.TestVerify.test01(TestVerify.java:20)102 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)103 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)104 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)105 at java.lang.reflect.Method.invoke(Unknown Source)106 at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)107 at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)108 at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)109 at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)110 at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)111 at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)112 at org.testng.TestRunner.privateRun(TestRunner.java:767)113 at org.testng.TestRunner.run(TestRunner.java:617)114 at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)115 at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)116 at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)117 at org.testng.SuiteRunner.run(SuiteRunner.java:240)118 at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)119 at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)120 at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)121 at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)122 at org.testng.TestNG.run(TestNG.java:1057)123 at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)124 at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)125 at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)126 ===============================================127 Default test128 Tests run: 1, Failures: 1, Skips: 0129 ===============================================*/130 131 }132 133 @Test134 public void verifyNotEqualsTest(){135 136 /* verifyNotEquals */137 Verify.verifyNotEquals("test!", "test1", "test1 matches"); // pass138 Verify.verifyNotEquals("test2", "test2", "test2 matches"); // fail (continue)139 Verify.verifyNotEquals("test!", "test3", "test3 matches"); // pass140 Verify.verifyNotEquals("test4", "test4", "test4 matches"); // fail (continue)141 Verify.verifyNotEquals("test!", "test5", "test5 matches"); // pass142 Verify.verifyNotEquals("test!", "test6", "test6 matches"); // pass143 Assert.assertNotEquals("test7", "test7", "test7 matches"); // fail (exit) 144 Assert.assertNotEquals("test!", "test8", "test8 matches"); // not run!145 Verify.verifyNotEquals("test!", "test9", "test9 matches"); // not run!146 147 // Output148 149/* FAILED: verifyNotEqualsTest150 java.lang.Throwable: Multiple failures (3)151 (1)org.muthu.VerificationError:test2 matches152 (2)org.muthu.VerificationError:test4 matches153 (3)java.lang.AssertionError:test7 matches154 Failure 1 of 3155 org.muthu.VerificationError: test2 matches156 at org.testng.Assert.fail(Assert.java:94)157 at org.testng.Assert.assertNotEquals(Assert.java:854)158 at org.muthu.Verify.verifyNotEquals(Verify.java:434)159 at org.muthu.TestVerify.verifyNotEqualsTest(TestVerify.java:143)160 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)161 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)162 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)163 at java.lang.reflect.Method.invoke(Unknown Source)164 at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)165 at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)166 at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)167 at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)168 at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)169 at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)170 at org.testng.TestRunner.privateRun(TestRunner.java:767)171 at org.testng.TestRunner.run(TestRunner.java:617)172 at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)173 at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)174 at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)175 at org.testng.SuiteRunner.run(SuiteRunner.java:240)176 at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)177 at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)178 at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)179 at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)180 at org.testng.TestNG.run(TestNG.java:1057)181 at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)182 at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)183 at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)184 Failure 2 of 3185 org.muthu.VerificationError: test4 matches186 at org.testng.Assert.fail(Assert.java:94)187 at org.testng.Assert.assertNotEquals(Assert.java:854)188 at org.muthu.Verify.verifyNotEquals(Verify.java:434)189 at org.muthu.TestVerify.verifyNotEqualsTest(TestVerify.java:145)190 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)191 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)192 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)193 at java.lang.reflect.Method.invoke(Unknown Source)194 at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)195 at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)196 at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)197 at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)198 at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)199 at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)200 at org.testng.TestRunner.privateRun(TestRunner.java:767)201 at org.testng.TestRunner.run(TestRunner.java:617)202 at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)203 at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)204 at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)205 at org.testng.SuiteRunner.run(SuiteRunner.java:240)206 at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)207 at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)208 at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)209 at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)210 at org.testng.TestNG.run(TestNG.java:1057)211 at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)212 at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)213 at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)214 Failure 3 of 3215 java.lang.AssertionError: test7 matches216 at org.testng.Assert.fail(Assert.java:94)217 at org.testng.Assert.assertNotEquals(Assert.java:854)218 at org.muthu.TestVerify.verifyNotEqualsTest(TestVerify.java:148)219 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)220 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)221 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)222 at java.lang.reflect.Method.invoke(Unknown Source)223 at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)224 at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)225 at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)226 at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)227 at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)228 at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)229 at org.testng.TestRunner.privateRun(TestRunner.java:767)230 at org.testng.TestRunner.run(TestRunner.java:617)231 at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)232 at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)233 at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)234 at org.testng.SuiteRunner.run(SuiteRunner.java:240)235 at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)236 at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)237 at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)238 at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)239 at org.testng.TestNG.run(TestNG.java:1057)240 at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)241 at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)242 at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)243 ===============================================244 Default test245 Tests run: 1, Failures: 1, Skips: 0246 ===============================================247*/248 }249 @Test250 public void verifyTrueTest(){251 252 /* verifyTrue */253 Verify.verifyTrue(true, "test1 condition is false"); // pass254 Verify.verifyTrue(false, "test2 condition is false"); // fail (continue)255 Verify.verifyTrue(true, "test3 condition is false"); // pass256 Verify.verifyTrue(false, "test4 condition is false"); // fail (continue)257 Verify.verifyTrue(true, "test5 condition is false"); // pass258 Verify.verifyTrue(true, "test6 condition is false"); // pass259 Assert.assertTrue(false, "test7 condition is false"); // fail (exit) 260 Assert.assertTrue(true, "test8 condition is false"); // not run!261 Verify.verifyTrue(true, "test9 condition is false"); // not run!262 263 // Output264 265/* Failure 1 of 3266 org.muthu.VerificationError: test2 condition is false expected [true] but found [false]267 at org.testng.Assert.fail(Assert.java:94)268 at org.testng.Assert.failNotEquals(Assert.java:494)269 at org.testng.Assert.assertTrue(Assert.java:42)270 at org.muthu.Verify.verifyTrue(Verify.java:18)271 at org.muthu.TestVerify.verifyTrueTest(TestVerify.java:265)272 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)273 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)274 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)275 at java.lang.reflect.Method.invoke(Unknown Source)276 at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)277 at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)278 at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)279 at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)280 at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)281 at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)282 at org.testng.TestRunner.privateRun(TestRunner.java:767)283 at org.testng.TestRunner.run(TestRunner.java:617)284 at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)285 at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)286 at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)287 at org.testng.SuiteRunner.run(SuiteRunner.java:240)288 at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)289 at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)290 at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)291 at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)292 at org.testng.TestNG.run(TestNG.java:1057)293 at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)294 at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)295 at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)296 Failure 2 of 3297 org.muthu.VerificationError: test4 condition is false expected [true] but found [false]298 at org.testng.Assert.fail(Assert.java:94)299 at org.testng.Assert.failNotEquals(Assert.java:494)300 at org.testng.Assert.assertTrue(Assert.java:42)301 at org.muthu.Verify.verifyTrue(Verify.java:18)302 at org.muthu.TestVerify.verifyTrueTest(TestVerify.java:267)303 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)304 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)305 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)306 at java.lang.reflect.Method.invoke(Unknown Source)307 at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)308 at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)309 at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)310 at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)311 at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)312 at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)313 at org.testng.TestRunner.privateRun(TestRunner.java:767)314 at org.testng.TestRunner.run(TestRunner.java:617)315 at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)316 at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)317 at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)318 at org.testng.SuiteRunner.run(SuiteRunner.java:240)319 at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)320 at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)321 at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)322 at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)323 at org.testng.TestNG.run(TestNG.java:1057)324 at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)325 at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)326 at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)327 Failure 3 of 3328 java.lang.AssertionError: test7 condition is false expected [true] but found [false]329 at org.testng.Assert.fail(Assert.java:94)330 at org.testng.Assert.failNotEquals(Assert.java:494)331 at org.testng.Assert.assertTrue(Assert.java:42)332 at org.muthu.TestVerify.verifyTrueTest(TestVerify.java:270)333 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)334 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)335 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)336 at java.lang.reflect.Method.invoke(Unknown Source)337 at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)338 at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)339 at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)340 at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)341 at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)342 at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)343 at org.testng.TestRunner.privateRun(TestRunner.java:767)344 at org.testng.TestRunner.run(TestRunner.java:617)345 at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)346 at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)347 at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)348 at org.testng.SuiteRunner.run(SuiteRunner.java:240)349 at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)350 at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)351 at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)352 at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)353 at org.testng.TestNG.run(TestNG.java:1057)354 at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)355 at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)356 at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)357 ===============================================358 Default test359 Tests run: 1, Failures: 1, Skips: 0360 ===============================================361*/362 }363 364 @Test365 public void exceptionTest(){366 367 String str = null;368 369 /* verifyEquals */370 Verify.verifyEquals("test1", "test1", "test1 doesn't match"); // pass371 Verify.verifyEquals("test!", "test2", "test2 doesn't match"); // fail (continue)372 Verify.verifyEquals("test3", "test3", "test3 doesn't match"); // pass373 374 /*375 * Test run will not continue if there is any exception/error (except Assertion error) during verification 376 */377 Verify.verifyEquals("test#", str.substring(0), "test4 doesn't match"); // fail (exit) 378 379 380 Verify.verifyEquals("test5", "test5", "test5 doesn't match"); // not run!381 Verify.verifyEquals("test6", "test6", "test6 doesn't match"); // not run!382 Assert.assertEquals("test$", "test7", "test7 doesn't match"); // not run! 383 Assert.assertEquals("test8", "test8", "test8 doesn't match"); // not run!384 Verify.verifyEquals("test9", "test9", "test9 doesn't match"); // not run!385 // Output386 387/* FAILED: exceptionTest388 java.lang.Throwable: Multiple failures (2)389 (1)org.muthu.VerificationError:test2 doesn't match expected [test2] but found [test!]390 (2)java.lang.NullPointerException:null391 Failure 1 of 2392 org.muthu.VerificationError: test2 doesn't match expected [test2] but found [test!]393 at org.testng.Assert.fail(Assert.java:94)394 at org.testng.Assert.failNotEquals(Assert.java:494)395 at org.testng.Assert.assertEquals(Assert.java:123)396 at org.testng.Assert.assertEquals(Assert.java:176)397 at org.muthu.Verify.verifyEquals(Verify.java:90)398 at org.muthu.TestVerify.exceptionTest(TestVerify.java:386)399 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)400 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)401 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)402 at java.lang.reflect.Method.invoke(Unknown Source)403 at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)404 at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)405 at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)406 at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)407 at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)408 at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)409 at org.testng.TestRunner.privateRun(TestRunner.java:767)410 at org.testng.TestRunner.run(TestRunner.java:617)411 at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)412 at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)413 at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)414 at org.testng.SuiteRunner.run(SuiteRunner.java:240)415 at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)416 at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)417 at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)418 at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)419 at org.testng.TestNG.run(TestNG.java:1057)420 at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)421 at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)422 at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)423 Failure 2 of 2424 java.lang.NullPointerException425 at org.muthu.TestVerify.exceptionTest(TestVerify.java:392)426 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)427 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)428 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)429 at java.lang.reflect.Method.invoke(Unknown Source)430 at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)431 at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)432 at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)433 at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)434 at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)435 at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)436 at org.testng.TestRunner.privateRun(TestRunner.java:767)437 at org.testng.TestRunner.run(TestRunner.java:617)438 at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)439 at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)440 at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)441 at org.testng.SuiteRunner.run(SuiteRunner.java:240)442 at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)443 at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)444 at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)445 at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)446 at org.testng.TestNG.run(TestNG.java:1057)447 at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)448 at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)449 at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)450 ===============================================451 Default test452 Tests run: 1, Failures: 1, Skips: 0453 ===============================================454*/455 }456 457}...

Full Screen

Full Screen

Source:SuiteRunner.java Github

copy

Full Screen

...26import java.util.Map;27import java.util.Set;28import com.google.inject.Injector;29/**30 * <CODE>SuiteRunner</CODE> is responsible for running all the tests included in one31 * suite. The test start is triggered by {@link #run()} method.32 *33 * @author Cedric Beust, Apr 26, 200434 */35public class SuiteRunner implements ISuite, Serializable, IInvokedMethodListener {36 /* generated */37 private static final long serialVersionUID = 5284208932089503131L;38 private static final String DEFAULT_OUTPUT_DIR = "test-output";39 private Map<String, ISuiteResult> m_suiteResults = Collections.synchronizedMap(Maps.<String, ISuiteResult>newLinkedHashMap());40 transient private List<TestRunner> m_testRunners = Lists.newArrayList();41 transient private Map<Class<? extends ISuiteListener>, ISuiteListener> m_listeners = Maps.newHashMap();42 transient private TestListenerAdapter m_textReporter = new TestListenerAdapter();43 private String m_outputDir; // DEFAULT_OUTPUT_DIR;44 private XmlSuite m_suite;45 private Injector m_parentInjector;46 transient private List<ITestListener> m_testListeners = Lists.newArrayList();47 transient private List<IClassListener> m_classListeners = Lists.newArrayList();48 transient private ITestRunnerFactory m_tmpRunnerFactory;49 transient private ITestRunnerFactory m_runnerFactory;50 transient private boolean m_useDefaultListeners = true;51 // The remote host where this suite was run, or null if run locally52 private String m_host;53 // The configuration54 transient private IConfiguration m_configuration;55 transient private ITestObjectFactory m_objectFactory;56 transient private Boolean m_skipFailedInvocationCounts = Boolean.FALSE;57 transient private List<IMethodInterceptor> m_methodInterceptors;58 private Map<Class<? extends IInvokedMethodListener>, IInvokedMethodListener> m_invokedMethodListeners;59 /** The list of all the methods invoked during this run */60 private List<IInvokedMethod> m_invokedMethods =61 Collections.synchronizedList(Lists.<IInvokedMethod>newArrayList());62 private List<ITestNGMethod> m_allTestMethods = Lists.newArrayList();63// transient private IAnnotationTransformer m_annotationTransformer = null;64 public SuiteRunner(IConfiguration configuration, XmlSuite suite,65 String outputDir)66 {67 this(configuration, suite, outputDir, null);68 }69 public SuiteRunner(IConfiguration configuration, XmlSuite suite, String outputDir,70 ITestRunnerFactory runnerFactory)71 {72 this(configuration, suite, outputDir, runnerFactory, false);73 }74 public SuiteRunner(IConfiguration configuration,75 XmlSuite suite,76 String outputDir,77 ITestRunnerFactory runnerFactory,78 boolean useDefaultListeners)79 {80 this(configuration, suite, outputDir, runnerFactory, useDefaultListeners,81 new ArrayList<IMethodInterceptor>() /* method interceptor */,82 null /* invoked method listeners */,83 null /* test listeners */,84 null /* class listeners */);85 }86 protected SuiteRunner(IConfiguration configuration,87 XmlSuite suite,88 String outputDir,89 ITestRunnerFactory runnerFactory,90 boolean useDefaultListeners,91 List<IMethodInterceptor> methodInterceptors,92 List<IInvokedMethodListener> invokedMethodListeners,93 List<ITestListener> testListeners,94 List<IClassListener> classListeners)95 {96 init(configuration, suite, outputDir, runnerFactory, useDefaultListeners, methodInterceptors, invokedMethodListeners, testListeners, classListeners);97 }98 private void init(IConfiguration configuration,99 XmlSuite suite,100 String outputDir,101 ITestRunnerFactory runnerFactory,102 boolean useDefaultListeners,103 List<IMethodInterceptor> methodInterceptors,104 List<IInvokedMethodListener> invokedMethodListener,105 List<ITestListener> testListeners,106 List<IClassListener> classListeners)107 {108 m_configuration = configuration;109 m_suite = suite;110 m_useDefaultListeners = useDefaultListeners;111 m_tmpRunnerFactory= runnerFactory;112 m_methodInterceptors = methodInterceptors != null ? methodInterceptors : new ArrayList<IMethodInterceptor>();113 setOutputDir(outputDir);114 m_objectFactory = m_configuration.getObjectFactory();115 if(m_objectFactory == null) {116 m_objectFactory = suite.getObjectFactory();117 }118 // Add our own IInvokedMethodListener119 m_invokedMethodListeners = Maps.newHashMap();120 if (invokedMethodListener != null) {121 for (IInvokedMethodListener listener : invokedMethodListener) {122 m_invokedMethodListeners.put(listener.getClass(), listener);123 }124 }125 m_invokedMethodListeners.put(getClass(), this);126 m_skipFailedInvocationCounts = suite.skipFailedInvocationCounts();127 if (null != testListeners) {128 m_testListeners.addAll(testListeners);129 }130 if (null != classListeners) {131 m_classListeners.addAll(classListeners);132 }133 m_runnerFactory = buildRunnerFactory();134 // Order the <test> tags based on their order of appearance in testng.xml135 List<XmlTest> xmlTests = m_suite.getTests();136 Collections.sort(xmlTests, new Comparator<XmlTest>() {137 @Override138 public int compare(XmlTest arg0, XmlTest arg1) {139 return arg0.getIndex() - arg1.getIndex();140 }141 });142 for (XmlTest test : xmlTests) {143 TestRunner tr = m_runnerFactory.newTestRunner(this, test, m_invokedMethodListeners.values(), m_classListeners);144 //145 // Install the method interceptor, if any was passed146 //147 for (IMethodInterceptor methodInterceptor : m_methodInterceptors) {148 tr.addMethodInterceptor(methodInterceptor);149 }150 // Reuse the same text reporter so we can accumulate all the results151 // (this is used to display the final suite report at the end)152 tr.addListener(m_textReporter);153 m_testRunners.add(tr);154 // Add the methods found in this test to our global count155 m_allTestMethods.addAll(Arrays.asList(tr.getAllTestMethods()));156 }157 }158 @Override159 public XmlSuite getXmlSuite() {160 return m_suite;161 }162 @Override163 public String getName() {164 return m_suite.getName();165 }166 public void setObjectFactory(ITestObjectFactory objectFactory) {167 m_objectFactory = objectFactory;168 }169 public void setReportResults(boolean reportResults) {170 m_useDefaultListeners = reportResults;171 }172 private void invokeListeners(boolean start) {173 for (ISuiteListener sl : m_listeners.values()) {174 if (start) {175 sl.onStart(this);176 }177 else {178 sl.onFinish(this);179 }180 }181 }182 private void setOutputDir(String outputdir) {183 if (isStringBlank(outputdir) && m_useDefaultListeners) {184 outputdir = DEFAULT_OUTPUT_DIR;185 }186 m_outputDir = (null != outputdir) ? new File(outputdir).getAbsolutePath()187 : null;188 }189 private ITestRunnerFactory buildRunnerFactory() {190 ITestRunnerFactory factory = null;191 if (null == m_tmpRunnerFactory) {192 factory = new DefaultTestRunnerFactory(m_configuration,193 m_testListeners.toArray(new ITestListener[m_testListeners.size()]),194 m_useDefaultListeners, m_skipFailedInvocationCounts);195 }196 else {197 factory = new ProxyTestRunnerFactory(198 m_testListeners.toArray(new ITestListener[m_testListeners.size()]),199 m_tmpRunnerFactory);200 }201 return factory;202 }203 @Override204 public String getParallel() {205 return m_suite.getParallel().toString();206 }207 public String getParentModule() {208 return m_suite.getParentModule();209 }210 @Override211 public String getGuiceStage() {212 return m_suite.getGuiceStage();213 }214 public Injector getParentInjector() {215 return m_parentInjector;216 }217 public void setParentInjector(Injector injector) {218 m_parentInjector = injector;219 }220 @Override221 public void run() {222 invokeListeners(true /* start */);223 try {224 privateRun();225 }226 finally {227 invokeListeners(false /* stop */);228 }229 }230 private void privateRun() {231 // Map for unicity, Linked for guaranteed order232 Map<Method, ITestNGMethod> beforeSuiteMethods= new LinkedHashMap<>();233 Map<Method, ITestNGMethod> afterSuiteMethods = new LinkedHashMap<>();234 IInvoker invoker = null;235 // Get the invoker and find all the suite level methods236 for (TestRunner tr: m_testRunners) {237 // TODO: Code smell. Invoker should belong to SuiteRunner, not TestRunner238 // -- cbeust239 invoker = tr.getInvoker();240 for (ITestNGMethod m : tr.getBeforeSuiteMethods()) {241 beforeSuiteMethods.put(m.getMethod(), m);242 }243 for (ITestNGMethod m : tr.getAfterSuiteMethods()) {244 afterSuiteMethods.put(m.getMethod(), m);245 }246 }247 //248 // Invoke beforeSuite methods (the invoker can be null249 // if the suite we are currently running only contains250 // a <file-suite> tag and no real tests)251 //252 if (invoker != null) {253 if(beforeSuiteMethods.values().size() > 0) {254 invoker.invokeConfigurations(null,255 beforeSuiteMethods.values().toArray(new ITestNGMethod[beforeSuiteMethods.size()]),256 m_suite, m_suite.getParameters(), null, /* no parameter values */257 null /* instance */258 );259 }260 Utils.log("SuiteRunner", 3, "Created " + m_testRunners.size() + " TestRunners");261 //262 // Run all the test runners263 //264 boolean testsInParallel = XmlSuite.ParallelMode.TESTS.equals(m_suite.getParallel());265 if (!testsInParallel) {266 runSequentially();267 }268 else {269 runInParallelTestMode();270 }271// SuitePlan sp = new SuitePlan();272// for (TestRunner tr : m_testRunners) {273// sp.addTestPlan(tr.getTestPlan());274// }275// sp.dump();276 //277 // Invoke afterSuite methods278 //279 if (afterSuiteMethods.values().size() > 0) {280 invoker.invokeConfigurations(null,281 afterSuiteMethods.values().toArray(new ITestNGMethod[afterSuiteMethods.size()]),282 m_suite, m_suite.getAllParameters(), null, /* no parameter values */283 null /* instance */);284 }285 }286 }287 private List<IReporter> m_reporters = Lists.newArrayList();288 private void addReporter(IReporter listener) {289 m_reporters.add(listener);290 }291 void addConfigurationListener(IConfigurationListener listener) {292 m_configuration.addConfigurationListener(listener);293 }294 public List<IReporter> getReporters() {295 return m_reporters;296 }297 private void runSequentially() {298 for (TestRunner tr : m_testRunners) {299 runTest(tr);300 }301 }302 private void runTest(TestRunner tr) {303 tr.run();304 ISuiteResult sr = new SuiteResult(m_suite, tr);305 m_suiteResults.put(tr.getName(), sr);306 }307 /**308 * Implement <suite parallel="tests">.309 * Since this kind of parallelism happens at the suite level, we need a special code path310 * to execute it. All the other parallelism strategies are implemented at the test level311 * in TestRunner#createParallelWorkers (but since this method deals with just one <test>312 * tag, it can't implement <suite parallel="tests">, which is why we're doing it here).313 */314 private void runInParallelTestMode() {315 List<Runnable> tasks= Lists.newArrayList(m_testRunners.size());316 for(TestRunner tr: m_testRunners) {317 tasks.add(new SuiteWorker(tr));318 }319 ThreadUtil.execute(tasks, m_suite.getThreadCount(),320 m_suite.getTimeOut(XmlTest.DEFAULT_TIMEOUT_MS), false);321 }322 private class SuiteWorker implements Runnable {323 private TestRunner m_testRunner;324 public SuiteWorker(TestRunner tr) {325 m_testRunner = tr;326 }327 @Override328 public void run() {329 Utils.log("[SuiteWorker]", 4, "Running XML Test '"330 + m_testRunner.getTest().getName() + "' in Parallel");331 runTest(m_testRunner);332 }333 }334 /**335 * Registers ISuiteListeners interested in reporting the result of the current336 * suite.337 *338 * @param reporter339 */340 protected void addListener(ISuiteListener reporter) {341 m_listeners.put(reporter.getClass(), reporter);342 }343 @Override344 public void addListener(ITestNGListener listener) {345 if (listener instanceof IInvokedMethodListener) {346 IInvokedMethodListener invokedMethodListener = (IInvokedMethodListener) listener;347 m_invokedMethodListeners.put(invokedMethodListener.getClass(), invokedMethodListener);348 }349 if (listener instanceof ISuiteListener) {350 addListener((ISuiteListener) listener);351 }352 if (listener instanceof IReporter) {353 addReporter((IReporter) listener);354 }355 if (listener instanceof IConfigurationListener) {356 addConfigurationListener((IConfigurationListener) listener);357 }358 }359 @Override360 public String getOutputDirectory() {361 return m_outputDir + File.separatorChar + getName();362 }363 @Override364 public Map<String, ISuiteResult> getResults() {365 return m_suiteResults;366 }367 /**368 * FIXME: should be removed?369 *370 * @see org.testng.ISuite#getParameter(java.lang.String)371 */372 @Override373 public String getParameter(String parameterName) {374 return m_suite.getParameter(parameterName);375 }376 /**377 * @see org.testng.ISuite#getMethodsByGroups()378 */379 @Override380 public Map<String, Collection<ITestNGMethod>> getMethodsByGroups() {381 Map<String, Collection<ITestNGMethod>> result = Maps.newHashMap();382 for (TestRunner tr : m_testRunners) {383 ITestNGMethod[] methods = tr.getAllTestMethods();384 for (ITestNGMethod m : methods) {385 String[] groups = m.getGroups();386 for (String groupName : groups) {387 Collection<ITestNGMethod> testMethods = result.get(groupName);388 if (null == testMethods) {389 testMethods = Lists.newArrayList();390 result.put(groupName, testMethods);391 }392 testMethods.add(m);393 }394 }395 }396 return result;397 }398 /**399 * @see org.testng.ISuite#getInvokedMethods()400 */401 @Override402 public Collection<ITestNGMethod> getInvokedMethods() {403 return getIncludedOrExcludedMethods(true /* included */);404 }405 /**406 * @see org.testng.ISuite#getExcludedMethods()407 */408 @Override409 public Collection<ITestNGMethod> getExcludedMethods() {410 return getIncludedOrExcludedMethods(false/* included */);411 }412 private Collection<ITestNGMethod> getIncludedOrExcludedMethods(boolean included) {413 List<ITestNGMethod> result= Lists.newArrayList();414 for (TestRunner tr : m_testRunners) {415 Collection<ITestNGMethod> methods = included ? tr.getInvokedMethods() : tr.getExcludedMethods();416 for (ITestNGMethod m : methods) {417 result.add(m);418 }419 }420 return result;421 }422 @Override423 public IObjectFactory getObjectFactory() {424 return m_objectFactory instanceof IObjectFactory ? (IObjectFactory) m_objectFactory : null;425 }426 @Override427 public IObjectFactory2 getObjectFactory2() {428 return m_objectFactory instanceof IObjectFactory2 ? (IObjectFactory2) m_objectFactory : null;429 }430 /**431 * Returns the annotation finder for the given annotation type.432 * @return the annotation finder for the given annotation type.433 */434 @Override435 public IAnnotationFinder getAnnotationFinder() {436 return m_configuration.getAnnotationFinder();437 }438 public static void ppp(String s) {439 System.out.println("[SuiteRunner] " + s);440 }441 /**442 * The default implementation of {@link ITestRunnerFactory}.443 */444 private static class DefaultTestRunnerFactory implements ITestRunnerFactory {445 private ITestListener[] m_failureGenerators;446 private boolean m_useDefaultListeners;447 private boolean m_skipFailedInvocationCounts;448 private IConfiguration m_configuration;449 public DefaultTestRunnerFactory(IConfiguration configuration,450 ITestListener[] failureListeners,451 boolean useDefaultListeners,452 boolean skipFailedInvocationCounts)453 {454 m_configuration = configuration;455 m_failureGenerators = failureListeners;456 m_useDefaultListeners = useDefaultListeners;457 m_skipFailedInvocationCounts = skipFailedInvocationCounts;458 }459 @Override460 public TestRunner newTestRunner(ISuite suite, XmlTest test,461 Collection<IInvokedMethodListener> listeners, List<IClassListener> classListeners) {462 boolean skip = m_skipFailedInvocationCounts;463 if (! skip) {464 skip = test.skipFailedInvocationCounts();465 }466 TestRunner testRunner = new TestRunner(m_configuration, suite, test,467 suite.getOutputDirectory(), suite.getAnnotationFinder(), skip,468 listeners, classListeners);469 if (m_useDefaultListeners) {470 testRunner.addListener(new TestHTMLReporter());471 testRunner.addListener(new JUnitXMLReporter());472 //TODO: Moved these here because maven2 has output reporters running473 //already, the output from these causes directories to be created with474 //files. This is not the desired behaviour of running tests in maven2.475 //Don't know what to do about this though, are people relying on these476 //to be added even with defaultListeners set to false?477 testRunner.addListener(new TextReporter(testRunner.getName(), TestRunner.getVerbose()));478 }479 for (ITestListener itl : m_failureGenerators) {480 testRunner.addListener(itl);481 }482 for (IConfigurationListener cl : m_configuration.getConfigurationListeners()) {483 testRunner.addConfigurationListener(cl);484 }485 return testRunner;486 }487 }488 private static class ProxyTestRunnerFactory implements ITestRunnerFactory {...

Full Screen

Full Screen

Source:NotificationRequestTest.java Github

copy

Full Screen

...81 " \"fileName\" : \"TestMethodWorker.java\",%n" +82 " \"lineNumber\" : 124%n" +83 " }, {%n" +84 " \"className\" : \"org.testng.internal.TestMethodWorker\",%n" +85 " \"methodName\" : \"run\",%n" +86 " \"fileName\" : \"TestMethodWorker.java\",%n" +87 " \"lineNumber\" : 108%n" +88 " }, {%n" +89 " \"className\" : \"org.testng.TestRunner\",%n" +90 " \"methodName\" : \"privateRun\",%n" +91 " \"fileName\" : \"TestRunner.java\",%n" +92 " \"lineNumber\" : 767%n" +93 " }, {%n" +94 " \"className\" : \"org.testng.TestRunner\",%n" +95 " \"methodName\" : \"run\",%n" +96 " \"fileName\" : \"TestRunner.java\",%n" +97 " \"lineNumber\" : 617%n" +98 " }, {%n" +99 " \"className\" : \"org.testng.SuiteRunner\",%n" +100 " \"methodName\" : \"runTest\",%n" +101 " \"fileName\" : \"SuiteRunner.java\",%n" +102 " \"lineNumber\" : 348%n" +103 " }, {%n" +104 " \"className\" : \"org.testng.SuiteRunner\",%n" +105 " \"methodName\" : \"runSequentially\",%n" +106 " \"fileName\" : \"SuiteRunner.java\",%n" +107 " \"lineNumber\" : 343%n" +108 " }, {%n" +109 " \"className\" : \"org.testng.SuiteRunner\",%n" +110 " \"methodName\" : \"privateRun\",%n" +111 " \"fileName\" : \"SuiteRunner.java\",%n" +112 " \"lineNumber\" : 305%n" +113 " }, {%n" +114 " \"className\" : \"org.testng.SuiteRunner\",%n" +115 " \"methodName\" : \"run\",%n" +116 " \"fileName\" : \"SuiteRunner.java\",%n" +117 " \"lineNumber\" : 254%n" +118 " }, {%n" +119 " \"className\" : \"org.testng.SuiteRunnerWorker\",%n" +120 " \"methodName\" : \"runSuite\",%n" +121 " \"fileName\" : \"SuiteRunnerWorker.java\",%n" +122 " \"lineNumber\" : 52%n" +123 " }, {%n" +124 " \"className\" : \"org.testng.SuiteRunnerWorker\",%n" +125 " \"methodName\" : \"run\",%n" +126 " \"fileName\" : \"SuiteRunnerWorker.java\",%n" +127 " \"lineNumber\" : 86%n" +128 " }, {%n" +129 " \"className\" : \"org.testng.TestNG\",%n" +130 " \"methodName\" : \"runSuitesSequentially\",%n" +131 " \"fileName\" : \"TestNG.java\",%n" +132 " \"lineNumber\" : 1224%n" +133 " }, {%n" +134 " \"className\" : \"org.testng.TestNG\",%n" +135 " \"methodName\" : \"runSuitesLocally\",%n" +136 " \"fileName\" : \"TestNG.java\",%n" +137 " \"lineNumber\" : 1149%n" +138 " }, {%n" +139 " \"className\" : \"org.testng.TestNG\",%n" +140 " \"methodName\" : \"run\",%n" +141 " \"fileName\" : \"TestNG.java\",%n" +142 " \"lineNumber\" : 1057%n" +143 " }, {%n" +144 " \"className\" : \"org.testng.remote.RemoteTestNG\",%n" +145 " \"methodName\" : \"run\",%n" +146 " \"fileName\" : \"RemoteTestNG.java\",%n" +147 " \"lineNumber\" : 111%n" +148 " }, {%n" +149 " \"className\" : \"org.testng.remote.RemoteTestNG\",%n" +150 " \"methodName\" : \"initAndRun\",%n" +151 " \"fileName\" : \"RemoteTestNG.java\",%n" +152 " \"lineNumber\" : 204%n" +153 " }, {%n" +154 " \"className\" : \"org.testng.remote.RemoteTestNG\",%n" +155 " \"methodName\" : \"main\",%n" +156 " \"fileName\" : \"RemoteTestNG.java\",%n" +157 " \"lineNumber\" : 175%n" +158 " }, {%n" +159 " \"className\" : \"org.testng.RemoteTestNGStarter\",%n" +160 " \"methodName\" : \"main\",%n" +161 " \"fileName\" : \"RemoteTestNGStarter.java\",%n" +162 " \"lineNumber\" : 125%n" +163 " } ],%n" +164 " \"cause\" : {%n" +165 " \"exceptionType\" : \"java.io.IOException\",%n" +166 " \"message\" : \"some thing\",%n" +167 " \"stackTrace\" : [ {%n" +168 " \"className\" : \"org.tiogasolutions.notify.notifier.request.NotificationRequestEntityTest\",%n" +169 " \"methodName\" : \"jsonTranslationTest\",%n" +170 " \"fileName\" : \"NotificationRequestEntityTest.java\",%n" +171 " \"lineNumber\" : 36%n" +172 " }, {%n" +173 " \"className\" : \"sun.reflect.NativeMethodAccessorImpl\",%n" +174 " \"methodName\" : \"invoke0\",%n" +175 " \"fileName\" : \"NativeMethodAccessorImpl.java\",%n" +176 " \"lineNumber\" : -2%n" +177 " }, {%n" +178 " \"className\" : \"sun.reflect.NativeMethodAccessorImpl\",%n" +179 " \"methodName\" : \"invoke\",%n" +180 " \"fileName\" : \"NativeMethodAccessorImpl.java\",%n" +181 " \"lineNumber\" : 62%n" +182 " }, {%n" +183 " \"className\" : \"sun.reflect.DelegatingMethodAccessorImpl\",%n" +184 " \"methodName\" : \"invoke\",%n" +185 " \"fileName\" : \"DelegatingMethodAccessorImpl.java\",%n" +186 " \"lineNumber\" : 43%n" +187 " }, {%n" +188 " \"className\" : \"java.lang.reflect.Method\",%n" +189 " \"methodName\" : \"invoke\",%n" +190 " \"fileName\" : \"Method.java\",%n" +191 " \"lineNumber\" : 483%n" +192 " }, {%n" +193 " \"className\" : \"org.testng.internal.MethodInvocationHelper\",%n" +194 " \"methodName\" : \"invokeMethod\",%n" +195 " \"fileName\" : \"MethodInvocationHelper.java\",%n" +196 " \"lineNumber\" : 85%n" +197 " }, {%n" +198 " \"className\" : \"org.testng.internal.Invoker\",%n" +199 " \"methodName\" : \"invokeMethod\",%n" +200 " \"fileName\" : \"Invoker.java\",%n" +201 " \"lineNumber\" : 696%n" +202 " }, {%n" +203 " \"className\" : \"org.testng.internal.Invoker\",%n" +204 " \"methodName\" : \"invokeTestMethod\",%n" +205 " \"fileName\" : \"Invoker.java\",%n" +206 " \"lineNumber\" : 882%n" +207 " }, {%n" +208 " \"className\" : \"org.testng.internal.Invoker\",%n" +209 " \"methodName\" : \"invokeTestMethods\",%n" +210 " \"fileName\" : \"Invoker.java\",%n" +211 " \"lineNumber\" : 1189%n" +212 " }, {%n" +213 " \"className\" : \"org.testng.internal.TestMethodWorker\",%n" +214 " \"methodName\" : \"invokeTestMethods\",%n" +215 " \"fileName\" : \"TestMethodWorker.java\",%n" +216 " \"lineNumber\" : 124%n" +217 " }, {%n" +218 " \"className\" : \"org.testng.internal.TestMethodWorker\",%n" +219 " \"methodName\" : \"run\",%n" +220 " \"fileName\" : \"TestMethodWorker.java\",%n" +221 " \"lineNumber\" : 108%n" +222 " }, {%n" +223 " \"className\" : \"org.testng.TestRunner\",%n" +224 " \"methodName\" : \"privateRun\",%n" +225 " \"fileName\" : \"TestRunner.java\",%n" +226 " \"lineNumber\" : 767%n" +227 " }, {%n" +228 " \"className\" : \"org.testng.TestRunner\",%n" +229 " \"methodName\" : \"run\",%n" +230 " \"fileName\" : \"TestRunner.java\",%n" +231 " \"lineNumber\" : 617%n" +232 " }, {%n" +233 " \"className\" : \"org.testng.SuiteRunner\",%n" +234 " \"methodName\" : \"runTest\",%n" +235 " \"fileName\" : \"SuiteRunner.java\",%n" +236 " \"lineNumber\" : 348%n" +237 " }, {%n" +238 " \"className\" : \"org.testng.SuiteRunner\",%n" +239 " \"methodName\" : \"runSequentially\",%n" +240 " \"fileName\" : \"SuiteRunner.java\",%n" +241 " \"lineNumber\" : 343%n" +242 " }, {%n" +243 " \"className\" : \"org.testng.SuiteRunner\",%n" +244 " \"methodName\" : \"privateRun\",%n" +245 " \"fileName\" : \"SuiteRunner.java\",%n" +246 " \"lineNumber\" : 305%n" +247 " }, {%n" +248 " \"className\" : \"org.testng.SuiteRunner\",%n" +249 " \"methodName\" : \"run\",%n" +250 " \"fileName\" : \"SuiteRunner.java\",%n" +251 " \"lineNumber\" : 254%n" +252 " }, {%n" +253 " \"className\" : \"org.testng.SuiteRunnerWorker\",%n" +254 " \"methodName\" : \"runSuite\",%n" +255 " \"fileName\" : \"SuiteRunnerWorker.java\",%n" +256 " \"lineNumber\" : 52%n" +257 " }, {%n" +258 " \"className\" : \"org.testng.SuiteRunnerWorker\",%n" +259 " \"methodName\" : \"run\",%n" +260 " \"fileName\" : \"SuiteRunnerWorker.java\",%n" +261 " \"lineNumber\" : 86%n" +262 " }, {%n" +263 " \"className\" : \"org.testng.TestNG\",%n" +264 " \"methodName\" : \"runSuitesSequentially\",%n" +265 " \"fileName\" : \"TestNG.java\",%n" +266 " \"lineNumber\" : 1224%n" +267 " }, {%n" +268 " \"className\" : \"org.testng.TestNG\",%n" +269 " \"methodName\" : \"runSuitesLocally\",%n" +270 " \"fileName\" : \"TestNG.java\",%n" +271 " \"lineNumber\" : 1149%n" +272 " }, {%n" +273 " \"className\" : \"org.testng.TestNG\",%n" +274 " \"methodName\" : \"run\",%n" +275 " \"fileName\" : \"TestNG.java\",%n" +276 " \"lineNumber\" : 1057%n" +277 " }, {%n" +278 " \"className\" : \"org.testng.remote.RemoteTestNG\",%n" +279 " \"methodName\" : \"run\",%n" +280 " \"fileName\" : \"RemoteTestNG.java\",%n" +281 " \"lineNumber\" : 111%n" +282 " }, {%n" +283 " \"className\" : \"org.testng.remote.RemoteTestNG\",%n" +284 " \"methodName\" : \"initAndRun\",%n" +285 " \"fileName\" : \"RemoteTestNG.java\",%n" +286 " \"lineNumber\" : 204%n" +287 " }, {%n" +288 " \"className\" : \"org.testng.remote.RemoteTestNG\",%n" +289 " \"methodName\" : \"main\",%n" +290 " \"fileName\" : \"RemoteTestNG.java\",%n" +291 " \"lineNumber\" : 175%n" +292 " }, {%n" +293 " \"className\" : \"org.testng.RemoteTestNGStarter\",%n" +...

Full Screen

Full Screen

Source:CliIntegrationTest.java Github

copy

Full Screen

...22 * Test the command line interface operation.23 */24public class CliIntegrationTest extends BaseCliIntegrationTest {25 /**26 * Checks if running {@code brooklyn help} produces the expected output.27 */28 @Test(groups = {"Integration","Broken"})29 public void testLaunchCliHelp() throws Throwable {30 final Process brooklyn = startBrooklyn("help");31 BrooklynCliTest test = new BrooklynCliTest(brooklyn) {32 @Override33 public void checkConsole() {34 assertConsoleOutput("usage: brooklyn"); // Usage info not present35 assertConsoleOutput("The most commonly used brooklyn commands are:");36 assertConsoleOutput("help Display help for available commands",37 "info Display information about brooklyn",38 "launch Starts a brooklyn application"); // List of common commands not present39 assertConsoleOutput("See 'brooklyn help <command>' for more information on a specific command.");40 assertConsoleErrorEmpty();41 }42 };43 testBrooklyn(brooklyn, test, 0);44 }45 /*46 Exception java.io.IOException47 48 Message: Cannot run program "./target/brooklyn-dist/bin/brooklyn": error=2, No such file or directory49 Stacktrace:50 51 52 at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)53 at org.apache.brooklyn.cli.BaseCliIntegrationTest.startBrooklyn(BaseCliIntegrationTest.java:75)54 at org.apache.brooklyn.cli.CliIntegrationTest.testLaunchCliApp(CliIntegrationTest.java:56)55 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)56 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)57 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)58 at java.lang.reflect.Method.invoke(Method.java:606)59 at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)60 at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)61 at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)62 at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)63 at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)64 at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)65 at org.testng.TestRunner.privateRun(TestRunner.java:767)66 at org.testng.TestRunner.run(TestRunner.java:617)67 at org.testng.SuiteRunner.runTest(SuiteRunner.java:348)68 at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343)69 at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305)70 at org.testng.SuiteRunner.run(SuiteRunner.java:254)71 at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)72 at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)73 at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)74 at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)75 at org.testng.TestNG.run(TestNG.java:1057)76 at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:115)77 at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeMulti(TestNGDirectoryTestSuite.java:205)78 at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:108)79 at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:111)80 at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)81 at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)82 at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)83 Caused by: java.io.IOException: error=2, No such file or directory84 at java.lang.UNIXProcess.forkAndExec(Native Method)85 at java.lang.UNIXProcess.<init>(UNIXProcess.java:186)86 at java.lang.ProcessImpl.start(ProcessImpl.java:130)87 at java.lang.ProcessBuilder.start(ProcessBuilder.java:1028)88 ... 30 more89 */90 /**91 * Checks if launching an application using {@code brooklyn launch} produces the expected output.92 */93 @Test(groups = {"Integration","Broken"})94 public void testLaunchCliApp() throws Throwable {95 final Process brooklyn = startBrooklyn("--verbose", "launch", "--stopOnKeyPress", "--app", "org.apache.brooklyn.cli.BaseCliIntegrationTest$TestApplication", "--location", "localhost", "--noConsole");96 BrooklynCliTest test = new BrooklynCliTest(brooklyn) {97 @Override98 public void checkConsole() {99 assertConsoleOutput("Launching brooklyn app:"); // Launch message not output100 assertNoConsoleOutput("Initiating Jersey application"); // Web console started101 assertConsoleOutput("Started application BasicApplicationImpl"); // Application not started102 assertConsoleOutput("Server started. Press return to stop."); // Server started message not output103 assertConsoleErrorEmpty();104 }105 };106 testBrooklyn(brooklyn, test, 0, true);107 }108 /**109 * Checks if a correct error and help message is given if using incorrect param.110 */111 @Test(groups = {"Integration","Broken"})112 public void testLaunchCliAppParamError() throws Throwable {113 final Process brooklyn = startBrooklyn("launch", "nothing", "--app");114 BrooklynCliTest test = new BrooklynCliTest(brooklyn) {115 @Override116 public void checkConsole() {117 assertConsoleError("Parse error: Required values for option 'application class or file' not provided");118 assertConsoleError("NAME", "SYNOPSIS", "OPTIONS", "COMMANDS");119 assertConsoleOutputEmpty();120 }121 };122 testBrooklyn(brooklyn, test, 1);123 }124 /*125 Exception java.io.IOException126 127 Message: Cannot run program "./target/brooklyn-dist/bin/brooklyn": error=2, No such file or directory128 Stacktrace:129 130 131 at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)132 at org.apache.brooklyn.cli.BaseCliIntegrationTest.startBrooklyn(BaseCliIntegrationTest.java:75)133 at org.apache.brooklyn.cli.CliIntegrationTest.testLaunchCliAppCommandError(CliIntegrationTest.java:96)134 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)135 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)136 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)137 at java.lang.reflect.Method.invoke(Method.java:606)138 at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)139 at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)140 at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)141 at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)142 at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)143 at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)144 at org.testng.TestRunner.privateRun(TestRunner.java:767)145 at org.testng.TestRunner.run(TestRunner.java:617)146 at org.testng.SuiteRunner.runTest(SuiteRunner.java:348)147 at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343)148 at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305)149 at org.testng.SuiteRunner.run(SuiteRunner.java:254)150 at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)151 at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)152 at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)153 at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)154 at org.testng.TestNG.run(TestNG.java:1057)155 at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:115)156 at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeMulti(TestNGDirectoryTestSuite.java:205)157 at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:108)158 at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:111)159 at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)160 at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)161 at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)162 Caused by: java.io.IOException: error=2, No such file or directory163 at java.lang.UNIXProcess.forkAndExec(Native Method)164 at java.lang.UNIXProcess.<init>(UNIXProcess.java:186)165 at java.lang.ProcessImpl.start(ProcessImpl.java:130)166 at java.lang.ProcessBuilder.start(ProcessBuilder.java:1028)167 ... 30 more168 */169 /**170 * Checks if a correct error and help message is given if using incorrect command.171 */172 @Test(groups = "Integration")173 public void testLaunchCliAppCommandError() throws Throwable {174 final Process brooklyn = startBrooklyn("biscuit");...

Full Screen

Full Screen

Source:RemoteTestNG.java Github

copy

Full Screen

...75 }76 }7778 @Override79 public void run() {80 IMessageSender sender = m_serPort != null81 ? new SerializedMessageSender(m_host, m_serPort, m_ack)82 : new StringMessageSender(m_host, m_port);83 final MessageHub msh = new MessageHub(sender);84 msh.setDebug(isDebug());85 try {86 msh.connect();87 // We couldn't do this until now in debug mode since the .xml file didn't exist yet.88 // Now that we have connected with the Eclipse client, we know that it created the .xml89 // file so we can proceed with the initialization90 initializeSuitesAndJarFile();9192 List<XmlSuite> suites = Lists.newArrayList();93 calculateAllSuites(m_suites, suites);94// System.out.println("Suites: " + m_suites.get(0).getChildSuites().size()95// + " and:" + suites.get(0).getChildSuites().size());96 if(suites.size() > 0) {9798 int testCount= 0;99100 for (XmlSuite suite : suites) {101 testCount += suite.getTests().size();102 }103104 GenericMessage gm= new GenericMessage(MessageHelper.GENERIC_SUITE_COUNT);105 gm.setSuiteCount(suites.size());106 gm.setTestCount(testCount);107 msh.sendMessage(gm);108109 addListener(new RemoteSuiteListener(msh));110 setTestRunnerFactory(new DelegatingTestRunnerFactory(buildTestRunnerFactory(), msh));111112// System.out.println("RemoteTestNG starting");113 super.run();114 }115 else {116 System.err.println("No test suite found. Nothing to run");117 }118 }119 catch(Throwable cause) {120 cause.printStackTrace(System.err);121 }122 finally {123// System.out.println("RemoteTestNG finishing: " + (getEnd() - getStart()) + " ms");124 msh.shutDown();125 if (! m_debug && ! m_dontExit) {126 System.exit(0);127 }128 }129 }130131 /**132 * Override by the plugin if you need to configure differently the <code>TestRunner</code>133 * (usually this is needed if different listeners/reporters are needed).134 * <b>Note</b>: you don't need to worry about the wiring listener, because it is added135 * automatically.136 */137 protected ITestRunnerFactory buildTestRunnerFactory() {138 if(null == m_customTestRunnerFactory) {139 m_customTestRunnerFactory= new ITestRunnerFactory() {140 @Override141 public TestRunner newTestRunner(ISuite suite, XmlTest xmlTest,142 Collection<IInvokedMethodListener> listeners, List<IClassListener> classListeners) {143 TestRunner runner =144 new TestRunner(getConfiguration(), suite, xmlTest,145 false /*skipFailedInvocationCounts */,146 listeners, classListeners);147 if (m_useDefaultListeners) {148 runner.addListener(new TestHTMLReporter());149 runner.addListener(new JUnitXMLReporter());150 }151152 return runner;153 }154 };155 }156157 return m_customTestRunnerFactory;158 }159160 public static void main(String[] args) throws ParameterException {161 CommandLineArgs cla = new CommandLineArgs();162 RemoteArgs ra = new RemoteArgs();163 new JCommander(Arrays.asList(cla, ra), args);164 m_dontExit = ra.dontExit;165 if (cla.port != null && ra.serPort != null) {166 throw new TestNGException("Can only specify one of " + CommandLineArgs.PORT167 + " and " + RemoteArgs.PORT);168 }169 m_debug = cla.debug;170 m_ack = ra.ack;171 if (m_debug) {172// while (true) {173 initAndRun(args, cla, ra);174// }175 }176 else {177 initAndRun(args, cla, ra);178 }179 }180181 private static void initAndRun(String[] args, CommandLineArgs cla, RemoteArgs ra) {182 RemoteTestNG remoteTestNg = new RemoteTestNG();183 if (m_debug) {184 // In debug mode, override the port and the XML file to a fixed location185 cla.port = Integer.parseInt(DEBUG_PORT);186 ra.serPort = cla.port;187 cla.suiteFiles = Arrays.asList(new String[] {188 DEBUG_SUITE_DIRECTORY + DEBUG_SUITE_FILE189 });190 }191 remoteTestNg.configure(cla);192 remoteTestNg.setHost(cla.host);193 m_serPort = ra.serPort;194 remoteTestNg.m_port = cla.port;195 if (isVerbose()) {196 StringBuilder sb = new StringBuilder("Invoked with ");197 for (String s : args) {198 sb.append(s).append(" ");199 }200 p(sb.toString());201// remoteTestNg.setVerbose(1);202// } else {203// remoteTestNg.setVerbose(0);204 }205 validateCommandLineParameters(cla);206 remoteTestNg.run();207// if (m_debug) {208// // Run in a loop if in debug mode so it is possible to run several launches209// // without having to relauch RemoteTestNG.210// while (true) {211// remoteTestNg.run();212// remoteTestNg.configure(cla);213// }214// } else {215// remoteTestNg.run();216// }217 }218219 private static void p(String s) {220 if (isVerbose()) {221 System.out.println("[RemoteTestNG] " + s);222 }223 }224225 public static boolean isVerbose() {226 boolean result = System.getProperty(PROPERTY_VERBOSE) != null || isDebug();227 return result;228 }229 ...

Full Screen

Full Screen

Source:JavaStackTraceParserTest.java Github

copy

Full Screen

...26 "\tat org.testng.internal.Invoker.invokeMethod(Invoker.java:673) [testng-6.0.1.jar:na]\n" +27 "\tat org.testng.internal.Invoker.invokeTestMethod(Invoker.java:846) [testng-6.0.1.jar:na]\n" +28 "\tat org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1170) [testng-6.0.1.jar:na]\n" +29 "\tat org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125) [testng-6.0.1.jar:na]\n" +30 "\tat org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109) [testng-6.0.1.jar:na]\n" +31 "\tat org.testng.TestRunner.runWorkers(TestRunner.java:1147) [testng-6.0.1.jar:na]\n" +32 "\tat org.testng.TestRunner.privateRun(TestRunner.java:749) [testng-6.0.1.jar:na]\n" +33 "\tat org.testng.TestRunner.run(TestRunner.java:600) [testng-6.0.1.jar:na]\n" +34 "\tat org.testng.SuiteRunner.runTest(SuiteRunner.java:317) [testng-6.0.1.jar:na]\n" +35 "\tat org.testng.SuiteRunner.runSequentially(SuiteRunner.java:312) [testng-6.0.1.jar:na]\n" +36 "\tat org.testng.SuiteRunner.privateRun(SuiteRunner.java:274) [testng-6.0.1.jar:na]\n" +37 "\tat org.testng.SuiteRunner.run(SuiteRunner.java:223) [testng-6.0.1.jar:na]\n" +38 "\tat org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) [testng-6.0.1.jar:na]\n" +39 "\tat org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) [testng-6.0.1.jar:na]\n" +40 "\tat org.testng.TestNG.runSuitesSequentially(TestNG.java:1039) [testng-6.0.1.jar:na]\n" +41 "\tat org.testng.TestNG.runSuitesLocally(TestNG.java:964) [testng-6.0.1.jar:na]\n" +42 "\tat org.testng.TestNG.run(TestNG.java:900) [testng-6.0.1.jar:na]\n" +43 "\tat org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:110) [testng-6.0.1.jar:na]\n" +44 "\tat org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205) [testng-6.0.1.jar:na]\n" +45 "\tat org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174) [testng-6.0.1.jar:na]\n" +46 "\tat org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:125) [testng-plugin.jar:na]\n" +47 "\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_65]\n" +48 "\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_65]\n" +49 "\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_65]\n" +50 "\tat java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_65]\n" +51 "\tat com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) [idea_rt.jar:na]\n";52 List<StackTraceLine> lines = parser.parse(stacktrace);53 assertThat(lines, hasSize(2));54 assertThat(lines, hasItems(55 new StackTraceLine("com.farpost.logwatcher.transport.CompositeEventListener", "onEntry",56 "CompositeEventListener.java", 22),57 new StackTraceLine("com.farpost.logwatcher.transport.CompositeEventListenerTest",58 "listenerShouldBeCalledEventIfPreviousListenerThrownAnException", "CompositeEventListenerTest.java", 33)59 ));60 }61 @Test62 public void testComplexCase() {63 parser.setAllowedPackagePrefix("com.farpost");64 String stacktrace = "com.farpost.search.TimeoutException: Deadline has been reached\n" +65 "\tat com.farpost.search.web.PerformSearchCallable.call(PerformSearchCallable.java:36)\n" +66 "\tat com.farpost.search.web.PerformSearchCallable.call(PerformSearchCallable.java:16)\n" +67 "\tat com.farpost.MdcSafeCallable.call(MdcSafeCallable.java:42)\n" +68 "\tat com.farpost.search.web.IndexNodeRestController.lambda$propagateResult$0(IndexNodeRestController.java:151)\n" +69 "\tat com.farpost.search.web.IndexNodeRestController$$Lambda$50/1280963737.call(Unknown Source)\n" +70 "\tat com.farpost.concurrent.PriorityCallable.call(PriorityCallable.java:26)\n" +71 "\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n" +72 "\tat com.farpost.concurrent.PriorityThreadPoolExecutor$ComparableRunnableFuture.run(PriorityThreadPoolExecutor.java:58)\n" +73 "\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\n" +74 "\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\n" +75 "\tat java.lang.Thread.run(Thread.java:745)";76 List<StackTraceLine> lines = parser.parse(stacktrace);77 assertThat(lines, hasSize(6));78 assertThat(lines, hasItem(new StackTraceLine("com.farpost.search.web.PerformSearchCallable", "call",79 "PerformSearchCallable.java", 36)));80 assertThat(lines, hasItem(new StackTraceLine("com.farpost.search.web.PerformSearchCallable", "call",81 "PerformSearchCallable.java", 16)));82 assertThat(lines, hasItem(new StackTraceLine("com.farpost.MdcSafeCallable", "call", "MdcSafeCallable.java", 42)));83 assertThat(lines, hasItem(new StackTraceLine("com.farpost.search.web.IndexNodeRestController",84 "lambda$propagateResult$0", "IndexNodeRestController.java", 151)));85 assertThat(lines, hasItem(new StackTraceLine("com.farpost.concurrent.PriorityCallable", "call",86 "PriorityCallable.java", 26)));87 assertThat(lines, hasItem(new StackTraceLine("com.farpost.concurrent.PriorityThreadPoolExecutor$ComparableRunnableFuture",88 "run", "PriorityThreadPoolExecutor.java", 58)));89 }90}...

Full Screen

Full Screen

Source:DependTest.java Github

copy

Full Screen

...39 at org.testng.internal.Invoker.invokeMethod(Invoker.java:645)40 at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:851)41 at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1177)42 at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)43 at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)44 at org.testng.TestRunner.privateRun(TestRunner.java:756)45 at org.testng.TestRunner.run(TestRunner.java:610)46 at org.testng.SuiteRunner.runTest(SuiteRunner.java:387)47 at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382)48 at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)49 at org.testng.SuiteRunner.run(SuiteRunner.java:289)50 at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)51 at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)52 at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293)53 at org.testng.TestNG.runSuitesLocally(TestNG.java:1218)54 at org.testng.TestNG.runSuites(TestNG.java:1133)55 at org.testng.TestNG.run(TestNG.java:1104)56 at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)57 at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)58 Test ignored.59 ===============================================60 Default Suite61 Total tests run: 2, Failures: 1, Skips: 162 */63}...

Full Screen

Full Screen

Source:TestRunner.java Github

copy

Full Screen

1package miniproject_Runner;2import org.junit.runner.RunWith;3import org.testng.annotations.AfterMethod;4import org.testng.annotations.Test;5import org.testng.annotations.BeforeClass;6import org.testng.annotations.DataProvider;7import cucumber.api.CucumberOptions;8import cucumber.api.junit.Cucumber;9import cucumber.api.testng.CucumberFeatureWrapper;10import cucumber.api.testng.TestNGCucumberRunner;11@RunWith(Cucumber.class)12@CucumberOptions(features="Features",13tags = {"@validLogin"},14glue = {"miniproject_StepDefinition"},15plugin= {"html:target/test_feature1.report"})16public class TestRunner {17 private TestNGCucumberRunner testRunner;18 19 @BeforeClass20 public void setUP()21 {22 testRunner = new TestNGCucumberRunner(TestRunner.class); 23 24 25 }26 @Test(description="login",dataProvider="features")27 public void login(CucumberFeatureWrapper cFeature)28 {29 testRunner.runCucumber(cFeature.getCucumberFeature());30 }31 @DataProvider(name="features")32 public Object[][] getFeatures()33 {34 return testRunner.provideFeatures();35 }36 @AfterMethod37 public void tearDown() throws InterruptedException38 { 39 40 testRunner.finish();41 }42}...

Full Screen

Full Screen

run

Using AI Code Generation

copy

Full Screen

1public class RunTestNGTest {2 public static void main(String[] args) {3 TestNG testNG = new TestNG();4 testNG.setTestClasses(new Class[] { TestNGTest.class });5 testNG.run();6 }7}8package com.coderpwh.learntestng;9import org.testng.annotations.Test;10public class TestNGTest {11 public void testMethod1() {12 System.out.println("TestNGTest.testMethod1");13 }14}

Full Screen

Full Screen

run

Using AI Code Generation

copy

Full Screen

1import org.testng.TestRunner2import org.testng.TestNG3import org.testng.xml.XmlSuite4import org.testng.xml.XmlTest5import org.testng.xml.XmlClass6def testRunner = new TestRunner()7testRunner.run()8import org.testng.TestNG9import org.testng.xml.XmlSuite10import org.testng.xml.XmlTest11import org.testng.xml.XmlClass12def testNG = new TestNG()13testNG.run()14import org.testng.TestNG15import org.testng.xml.XmlSuite16import org.testng.xml.XmlTest17import org.testng.xml.XmlClass18def testNG = new TestNG()19testNG.run()20import org.testng.TestNG21import org.testng.xml.XmlSuite22import org.testng.xml.XmlTest23import org.testng.xml.XmlClass24def testNG = new TestNG()25testNG.run()26import org.testng.TestNG27import org.testng.xml.XmlSuite28import org.testng.xml.XmlTest29import org.testng.xml.XmlClass30def testNG = new TestNG()31testNG.run()32import org.testng.TestNG33import org.testng.xml.XmlSuite34import org.testng.xml.XmlTest35import org.testng.xml.XmlClass36def testNG = new TestNG()37testNG.run()38import org.testng.TestNG39import org.testng.xml.XmlSuite40import org.testng.xml.XmlTest41import org.testng.xml.XmlClass42def testNG = new TestNG()43testNG.run()44import org.testng.TestNG45import org.testng.xml.XmlSuite46import org.testng.xml.XmlTest47import org.testng.xml.XmlClass48def testNG = new TestNG()49testNG.run()50import org.testng.TestNG51import org.testng.xml.XmlSuite52import org.testng.xml.XmlTest53import org.testng.xml.XmlClass54def testNG = new TestNG()55testNG.run()56import org.testng.TestNG57import org.testng.xml.XmlSuite58import org.testng.xml.XmlTest59import org.testng.xml

Full Screen

Full Screen

run

Using AI Code Generation

copy

Full Screen

1import org.testng.TestNG;2import org.testng.xml.XmlSuite;3import org.testng.xml.XmlTest;4import org.testng.xml.Parser;5import org.testng.xml.XmlClass;6import org.testng.xml.XmlPackage;7import org.testng.xml.XmlGroups;8import org.testng.xml.XmlGroup;9import java.util.List;10import java.util.ArrayList;11import java.util.Map;12import java.util.HashMap;13import java.util.Iterator;14import java.io.File;15import java.io.FileInputStream;16import java.io.FileNotFoundException;17import java.io.IOException;18import java.io.BufferedReader;19import java.io.InputStreamReader;20import java.io.FileReader;21import java.io.FileWriter;22import java.io.PrintWriter;23import java.nio.file.Files;24import java.nio.file.Paths;25import java.util.stream.Stream;26import java.util.stream.Collectors;27import java.util.regex.Pattern;28import java.util.regex.Matcher;29import java.util.Arrays;30import java.util.Properties;31import java.util.Date;32import java.text.SimpleDateFormat;33import org.apache.commons.lang3.StringUtils;34import org.apache.commons.lang3.ArrayUtils;35import org.apache.commons.lang3.text.WordUtils;36import org.apache.commons.lang3.math.NumberUtils;37import org.apache.commons.lang3.exception.ExceptionUtils;38import org.apache.commons.io.FileUtils;39import org.apache.commons.io.FilenameUtils;40import org.apache.commons.io.IOUtils;41import org.apache.commons.io.filefilter.WildcardFileFilter;42import org.apache.commons.io.filefilter.TrueFileFilter;43import org.apache.commons.io.filefilter.FalseFileFilter;44import org.apache.commons.io.filefilter.HiddenFileFilter;45import org.apache.commons.io.filefilter.SuffixFileFilter;46import org.apache.commons.io.filefilter.PrefixFileFilter;47import org.apache.commons.io.filefilter.NameFileFilter;48import org.apache.commons.io.filefilter.RegexFileFilter;49import org.apache.commons.io.filefilter.AndFileFilter;50import org.apache.commons.io.filefilter.OrFileFilter;51import org.apache.commons.io.filefilter.NotFileFilter;52import org.apache.commons.io.filefilter.IOFileFilter;53import org.apache.commons.io.filefilter.AgeFileFilter;54import org.apache.commons.io.filefilter.SizeFileFilter;55import org.apache.commons.io.filefilter.CanReadFileFilter;56import org.apache.commons.io.filefilter.CanWriteFileFilter;57import org.apache.commons.io.filefilter.CanExecuteFileFilter;58import org.apache.commons.io.filefilter.DirectoryFileFilter;59import org.apache.commons.io.filefilter.FileFileFilter;60import org.apache.commons.io.filefilter.EmptyFileFilter;61import org.apache.commons.io.filefilter.SizeFileFilter

Full Screen

Full Screen

run

Using AI Code Generation

copy

Full Screen

1public class TestngRunner {2 public static void main(String[] args) {3 TestRunner tr = new TestRunner();4 tr.run(new TestSuite(SimpleTest.class));5 }6}7public class TestngRunner {8 public static void main(String[] args) {9 TestNG testng = new TestNG();10 testng.setTestClasses(new Class[] { SimpleTest.class });11 testng.run();12 }13}

Full Screen

Full Screen

run

Using AI Code Generation

copy

Full Screen

1import org.testng.TestRunner;2public class TestNGRunner {3 public static void main(String[] args) {4 TestRunner testRunner = new TestRunner();5 testRunner.run(new String[]{"testng.xml"});6 }7}

Full Screen

Full Screen

TestNG tutorial

TestNG is a Java-based open-source framework for test automation that includes various test types, such as unit testing, functional testing, E2E testing, etc. TestNG is in many ways similar to JUnit and NUnit. But in contrast to its competitors, its extensive features make it a lot more reliable framework. One of the major reasons for its popularity is its ability to structure tests and improve the scripts' readability and maintainability. Another reason can be the important characteristics like the convenience of using multiple annotations, reliance, and priority that make this framework popular among developers and testers for test design. You can refer to the TestNG tutorial to learn why you should choose the TestNG framework.

Chapters

  1. JUnit 5 vs. TestNG: Compare and explore the core differences between JUnit 5 and TestNG from the Selenium WebDriver viewpoint.
  2. Installing TestNG in Eclipse: Start installing the TestNG Plugin and learn how to set up TestNG in Eclipse to begin constructing a framework for your test project.
  3. Create TestNG Project in Eclipse: Get started with creating a TestNG project and write your first TestNG test script.
  4. Automation using TestNG: Dive into how to install TestNG in this Selenium TestNG tutorial, the fundamentals of developing an automation script for Selenium automation testing.
  5. Parallel Test Execution in TestNG: Here are some essential elements of parallel testing with TestNG in this Selenium TestNG tutorial.
  6. Creating TestNG XML File: Here is a step-by-step tutorial on creating a TestNG XML file to learn why and how it is created and discover how to run the TestNG XML file being executed in parallel.
  7. Automation with Selenium, Cucumber & TestNG: Explore for an in-depth tutorial on automation using Selenium, Cucumber, and TestNG, as TestNG offers simpler settings and more features.
  8. JUnit Selenium Tests using TestNG: Start running your regular and parallel tests by looking at how to run test cases in Selenium using JUnit and TestNG without having to rewrite the tests.
  9. Group Test Cases in TestNG: Along with the explanation and demonstration using relevant TestNG group examples, learn how to group test cases in TestNG.
  10. Prioritizing Tests in TestNG: Get started with how to prioritize test cases in TestNG for Selenium automation testing.
  11. Assertions in TestNG: Examine what TestNG assertions are, the various types of TestNG assertions, and situations that relate to Selenium automated testing.
  12. DataProviders in TestNG: Deep dive into learning more about TestNG's DataProvider and how to effectively use it in our test scripts for Selenium test automation.
  13. Parameterization in TestNG: Here are the several parameterization strategies used in TestNG tests and how to apply them in Selenium automation scripts.
  14. TestNG Listeners in Selenium WebDriver: Understand the various TestNG listeners to utilize them effectively for your next plan when working with TestNG and Selenium automation.
  15. TestNG Annotations: Learn more about the execution order and annotation attributes, and refer to the prerequisites required to set up TestNG.
  16. TestNG Reporter Log in Selenium: Find out how to use the TestNG Reporter Log and learn how to eliminate the need for external software with TestNG Reporter Class to boost productivity.
  17. TestNG Reports in Jenkins: Discover how to generate TestNG reports in Jenkins if you want to know how to create, install, and share TestNG reports in Jenkins.

Certification

You can push your abilities to do automated testing using TestNG and advance your career by earning a TestNG certification. Check out our TestNG certification.

YouTube

Watch this complete tutorial to learn how you can leverage the capabilities of the TestNG framework for Selenium automation testing.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful