@@ -35,7 +35,7 @@ @implementation BluepillTests
35
35
36
36
- (void )setUp {
37
37
[super setUp ];
38
-
38
+
39
39
self.continueAfterFailure = NO ;
40
40
NSString *hostApplicationPath = [BPTestHelper sampleAppPath ];
41
41
NSString *testBundlePath = [BPTestHelper sampleAppNegativeTestsBundlePath ];
@@ -222,11 +222,11 @@ - (void)testReportWithAppCrashingAndRetryOnlyFailedTestsSet {
222
222
self.config .outputDirectory = outputDir;
223
223
self.config .errorRetriesCount = @1 ;
224
224
self.config .failureTolerance = @1 ;
225
- self.config .onlyRetryFailed = YES ;
226
-
225
+ self.config .onlyRetryFailed = TRUE ;
226
+
227
227
BPExitStatus exitCode = [[[Bluepill alloc ] initWithConfiguration: self .config] run ];
228
228
XCTAssertTrue (exitCode == BPExitStatusAppCrashed);
229
-
229
+
230
230
NSString *junitReportPath = [outputDir stringByAppendingPathComponent: @" TEST-BPSampleAppCrashingTests-1-results.xml" ];
231
231
NSLog (@" JUnit file: %@ " , junitReportPath);
232
232
NSString *expectedFilePath = [[[NSBundle bundleForClass: [self class ]] resourcePath ] stringByAppendingPathComponent: @" crash_tests_with_retry_attempt_1.xml" ];
@@ -248,7 +248,7 @@ - (void)DISABLE_testAppCrashingAndRetryReportsCorrectExitCode {
248
248
self.config .testing_crashOnAttempt = @1 ;
249
249
self.config .errorRetriesCount = @2 ;
250
250
self.config .failureTolerance = @1 ;
251
- self.config .onlyRetryFailed = YES ;
251
+ self.config .onlyRetryFailed = TRUE ;
252
252
253
253
BPExitStatus exitCode = [[[Bluepill alloc ] initWithConfiguration: self .config] run ];
254
254
XCTAssertTrue (exitCode == BPExitStatusAllTestsPassed);
@@ -326,11 +326,11 @@ - (void)testReportWithAppHangingTestsShouldReturnFailure {
326
326
}
327
327
328
328
/* *
329
- Execution plan: TIMEOUT, CRASH, PASS
329
+ Execution plan: TIMEOUT, CRASH (not retried)
330
330
*/
331
331
- (void )testReportFailureOnTimeoutCrashAndPass {
332
332
self.config .stuckTimeout = @6 ;
333
- self.config .testing_ExecutionPlan = @" TIMEOUT CRASH PASS " ;
333
+ self.config .testing_ExecutionPlan = @" TIMEOUT CRASH" ;
334
334
self.config .errorRetriesCount = @4 ;
335
335
self.config .onlyRetryFailed = TRUE ;
336
336
NSString *testBundlePath = [BPTestHelper sampleAppHangingTestsBundlePath ];
@@ -345,6 +345,48 @@ - (void)testReportFailureOnTimeoutCrashAndPass {
345
345
XCTAssertTrue (exitCode == BPExitStatusAppCrashed);
346
346
}
347
347
348
+ /* *
349
+ Execution plan: TIMEOUT, CRASH, CRASH w/ flag to retry crashes and consider them non-fatal
350
+ */
351
+ - (void )testReportFailureOnTimeoutCrashAndCrashOnRetry {
352
+ self.config .stuckTimeout = @6 ;
353
+ self.config .retryAppCrashTests = TRUE ;
354
+ self.config .testing_ExecutionPlan = @" TIMEOUT CRASH CRASH" ;
355
+ self.config .errorRetriesCount = @2 ;
356
+ self.config .onlyRetryFailed = TRUE ;
357
+ NSString *testBundlePath = [BPTestHelper sampleAppHangingTestsBundlePath ];
358
+ self.config .testBundlePath = testBundlePath;
359
+ NSString *tempDir = NSTemporaryDirectory ();
360
+ NSError *error;
361
+ NSString *outputDir = [BPUtils mkdtemp: [NSString stringWithFormat: @" %@ /AppHangingTestsSetTempDir" , tempDir] withError: &error];
362
+ NSLog (@" output directory is %@ " , outputDir);
363
+ self.config .outputDirectory = outputDir;
364
+
365
+ BPExitStatus exitCode = [[[Bluepill alloc ] initWithConfiguration: self .config] run ];
366
+ XCTAssertTrue (exitCode == (BPExitStatusTestTimeout | BPExitStatusAppCrashed));
367
+ }
368
+
369
+ /* *
370
+ Execution plan: TIMEOUT, CRASH, PASS w/ flag to retry crashes and consider them non-fatal
371
+ */
372
+ - (void )testReportSuccessOnTimeoutCrashAndPassOnRetry {
373
+ self.config .stuckTimeout = @6 ;
374
+ self.config .retryAppCrashTests = TRUE ;
375
+ self.config .testing_ExecutionPlan = @" TIMEOUT CRASH PASS" ;
376
+ self.config .errorRetriesCount = @4 ;
377
+ self.config .onlyRetryFailed = TRUE ;
378
+ NSString *testBundlePath = [BPTestHelper sampleAppHangingTestsBundlePath ];
379
+ self.config .testBundlePath = testBundlePath;
380
+ NSString *tempDir = NSTemporaryDirectory ();
381
+ NSError *error;
382
+ NSString *outputDir = [BPUtils mkdtemp: [NSString stringWithFormat: @" %@ /AppHangingTestsSetTempDir" , tempDir] withError: &error];
383
+ NSLog (@" output directory is %@ " , outputDir);
384
+ self.config .outputDirectory = outputDir;
385
+
386
+ BPExitStatus exitCode = [[[Bluepill alloc ] initWithConfiguration: self .config] run ];
387
+ XCTAssertTrue (exitCode == BPExitStatusAllTestsPassed);
388
+ }
389
+
348
390
/* *
349
391
Execution plan: CRASH
350
392
*/
@@ -387,6 +429,28 @@ - (void)testReportFailureOnCrashAndTimeoutTests {
387
429
XCTAssertTrue (exitCode == BPExitStatusAppCrashed);
388
430
}
389
431
432
+ /* *
433
+ Execution plan: Test crashes but passes on retry w/ retry app crash tests flag set
434
+ */
435
+ - (void )testReportSuccessOnAppCrashTestPassesOnRetry {
436
+ self.config .stuckTimeout = @6 ;
437
+ self.config .retryAppCrashTests = TRUE ;
438
+ self.config .testing_ExecutionPlan = @" CRASH PASS; SKIP PASS" ;
439
+ self.config .onlyRetryFailed = TRUE ;
440
+ self.config .failureTolerance = @1 ;
441
+ self.config .errorRetriesCount = @2 ;
442
+ NSString *testBundlePath = [BPTestHelper sampleAppHangingTestsBundlePath ];
443
+ self.config .testBundlePath = testBundlePath;
444
+ NSString *tempDir = NSTemporaryDirectory ();
445
+ NSError *error;
446
+ NSString *outputDir = [BPUtils mkdtemp: [NSString stringWithFormat: @" %@ /AppHangingTestsSetTempDir" , tempDir] withError: &error];
447
+ NSLog (@" output directory is %@ " , outputDir);
448
+ self.config .outputDirectory = outputDir;
449
+
450
+ BPExitStatus exitCode = [[[Bluepill alloc ] initWithConfiguration: self .config] run ];
451
+ XCTAssertTrue (exitCode == BPExitStatusAllTestsPassed);
452
+ }
453
+
390
454
/* *
391
455
Execution plan: One test CRASHes and another one keeps timing out
392
456
*/
@@ -457,7 +521,7 @@ - (void)testReportSuccessOnTimeoutAndPassOnRetry {
457
521
self.config .stuckTimeout = @6 ;
458
522
self.config .testing_ExecutionPlan = @" TIMEOUT PASS" ;
459
523
self.config .errorRetriesCount = @4 ;
460
- self.config .onlyRetryFailed = YES ;
524
+ self.config .onlyRetryFailed = TRUE ;
461
525
self.config .failureTolerance = @0 ; // Not relevant
462
526
NSString *testBundlePath = [BPTestHelper sampleAppHangingTestsBundlePath ];
463
527
self.config .testBundlePath = testBundlePath;
@@ -478,7 +542,7 @@ - (void)testReportFailureOnTimeoutAndNoRetry {
478
542
self.config .stuckTimeout = @6 ;
479
543
self.config .testing_ExecutionPlan = @" TIMEOUT" ;
480
544
self.config .errorRetriesCount = @2 ;
481
- self.config .onlyRetryFailed = NO ;
545
+ self.config .onlyRetryFailed = FALSE ;
482
546
self.config .failureTolerance = @1 ; // Not relevant since it's not a test failure
483
547
NSString *testBundlePath = [BPTestHelper sampleAppHangingTestsBundlePath ];
484
548
self.config .testBundlePath = testBundlePath;
@@ -500,7 +564,7 @@ - (void)testReportSuccessOnFailedTestAndPassOnRetryAll {
500
564
self.config .testing_ExecutionPlan = @" FAIL PASS" ;
501
565
self.config .errorRetriesCount = @4 ;
502
566
self.config .onlyRetryFailed = NO ; // Indicates to retry all tests when a test fails
503
- self.config .failureTolerance = @1 ; // Even though failureTolerance is non-zero it wouldn't retry because onlyRetryFailed = NO
567
+ self.config .failureTolerance = @1 ;
504
568
NSString *testBundlePath = [BPTestHelper sampleAppHangingTestsBundlePath ];
505
569
self.config .testBundlePath = testBundlePath;
506
570
NSString *tempDir = NSTemporaryDirectory ();
@@ -578,7 +642,7 @@ - (void)testRetryOnlyFailures {
578
642
self.config .outputDirectory = outputDir;
579
643
self.config .errorRetriesCount = @100 ;
580
644
self.config .failureTolerance = @1 ;
581
- self.config .onlyRetryFailed = YES ;
645
+ self.config .onlyRetryFailed = TRUE ;
582
646
BPExitStatus exitCode = [[[Bluepill alloc ] initWithConfiguration: self .config] run ];
583
647
XCTAssert (exitCode == BPExitStatusTestsFailed);
584
648
// Make sure all tests started on the first run
@@ -626,7 +690,7 @@ - (void)testKeepSimulatorWithAppCrashingTestsSet {
626
690
NSString *testBundlePath = [BPTestHelper sampleAppCrashingTestsBundlePath ];
627
691
self.config .testBundlePath = testBundlePath;
628
692
self.config .keepSimulator = YES ;
629
-
693
+
630
694
Bluepill *bp = [[Bluepill alloc ] initWithConfiguration: self .config];
631
695
BPExitStatus exitCode = [bp run ];
632
696
XCTAssert (exitCode == BPExitStatusAppCrashed);
@@ -639,7 +703,7 @@ - (void)testKeepSimulatorWithAppHangingTestsSet {
639
703
self.config .testBundlePath = testBundlePath;
640
704
self.config .keepSimulator = YES ;
641
705
self.config .testing_ExecutionPlan = @" TIMEOUT" ;
642
-
706
+
643
707
Bluepill *bp = [[Bluepill alloc ] initWithConfiguration: self .config];
644
708
BPExitStatus exitCode = [bp run ];
645
709
XCTAssert (exitCode == BPExitStatusTestTimeout);
@@ -649,15 +713,15 @@ - (void)testDeleteSimulatorOnly {
649
713
NSString *testBundlePath = [BPTestHelper sampleAppBalancingTestsBundlePath ];
650
714
self.config .testBundlePath = testBundlePath;
651
715
self.config .keepSimulator = YES ;
652
-
716
+
653
717
Bluepill *bp = [[Bluepill alloc ] initWithConfiguration: self .config];
654
718
BPExitStatus exitCode = [bp run ];
655
719
XCTAssert (exitCode == BPExitStatusAllTestsPassed);
656
720
XCTAssertNotNil (bp.test_simulatorUDID );
657
-
721
+
658
722
self.config .deleteSimUDID = bp.test_simulatorUDID ;
659
723
XCTAssertNotNil (self.config .deleteSimUDID );
660
-
724
+
661
725
Bluepill *bp2 = [[Bluepill alloc ] initWithConfiguration: self .config];
662
726
BPExitStatus exitCode2 = [bp2 run ];
663
727
XCTAssert (exitCode2 == BPExitStatusSimulatorDeleted);
0 commit comments