Best way to handle non-zero exit code from test results
Asked by Ross Attrill:

I have a test suite which return a non-zero exit code if there is one or more failing test.

The test suite is running Perl 'prove' command using \`--harness TAP::Harness::JUnit\` to format the results as JUnit.

The logs report that the task is set to fail because an exit code of 1 has been reported in the sub-process.

|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
| Test Summary Report  |
| 09-Sep-2013 11:30:48 | -------------------                                                                                                                                   |
| 09-Sep-2013 11:30:48 | t/Exl/Portfolio/PortfolioService.t (Wstat: 256 Tests: 8 Failed: 1)                                                                                    |
| 09-Sep-2013 11:30:48 | Failed test: 8                                                                                                                                        |
| 09-Sep-2013 11:30:48 | Non-zero exit status: 1                                                                                                                               |
| 09-Sep-2013 11:30:48 | Files=1, Tests=8, 3.01914 wallclock secs ( 0.02 usr + 0.03 sys = 0.05 CPU)                                                                            |
| 09-Sep-2013 11:30:48 | Result: FAIL                                                                                                                                          |
| 09-Sep-2013 11:30:48 | Failing task since return code of \[C:\\opt\\Atlassian\\Bamboo\\temp\\EF-EDS-JOB1-20-ScriptBuildTask-1386811734320945865.bat\] was 1 while expected 0 |

As a result I get the final status of:

No failed tests found, a possible compilation error occurred.

and test results are not parsed.

I have tried adding an \`exit \\B 0\` to my script task but this does not seem to work.

I have tried adding system parameters to a wrapper.conf file that I have created in the \\conf sub-directory as per

<https://confluence.atlassian.com/display/BAMBOO/Bamboo+indicates+that+my+Ant+or+Maven+builds+failed,+even+though+they+were+successful>

and

<https://confluence.atlassian.com/display/BAMBOO/Configuring+system+properties>

The file contains this:

```
atlassian.bamboo.builder.successMarker=Result: PASSatlassian.bamboo.builder.failedMarker=Result: FAIL
```

Is there anything that I can do to get the JUnit Parser to parse the test results if a non-zero exit code is returned. See also this discussion:

<https://groups.google.com/forum/#!topic/cukes/w86pPYPtc5k>

<br />


Answers:
author: Ross Attrill
body: Sultan at Atlassian support solved this for me. In the task I set the checkbox 'Run as PowerShell script' to true. I then set my script as

```
cmd /c path_to_my_batch_file.bat
```

and results are correctly parsed. This looks like a workaround - but it achieves the result.

comments: author: shubham patni
body: HI Ross, In my case I'm getting following error. I'm following guideline suggested **[here](http://craigthomas.ca/blog/2014/10/14/continuous-integration-with-android-and-bamboo/#comment-3962)** **:**   

31-Jan-2017 02:16:53 FAILURE: Build failed with an exception.  
31-Jan-2017 02:16:53   
31-Jan-2017 02:16:53 \* What went wrong:  
31-Jan-2017 02:16:53 A problem occurred configuring project ':app'.  
**31-Jan-2017 02:16:53 \> java.lang.NullPointerException (no error message)**   
31-Jan-2017 02:16:53   
31-Jan-2017 02:16:53 \* Try:  
31-Jan-2017 02:16:53 Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.  
31-Jan-2017 02:16:53   
31-Jan-2017 02:16:53 BUILD FAILED  
31-Jan-2017 02:16:53   
31-Jan-2017 02:16:53 Total time: 1 mins 2.42 secs  
31-Jan-2017 02:16:53 Failing task since return code of \[/bin/sh /var/folders/m9/03dpsmkd009gfygtdzx86m800000gn/T/AA-DB-JOB1-7-ScriptBuildTask-**2390776201064983710.sh ANDROID_HOME=/Users/shubham/Library/Android/sdk\] was 1 while expected 0**   
31-Jan-2017 02:16:53 Finished task 'Droid Build Script' with result: Failed  
31-Jan-2017 02:16:53 Running post build plugin 'Docker Container Cleanup'  
31-Jan-2017 02:16:53 Running post build plugin 'NCover Results Collector'  
31-Jan-2017 02:16:53 Running post build plugin 'Clover Results Collector'  
31-Jan-2017 02:16:53 Running post build plugin 'npm Cache Cleanup'  
31-Jan-2017 02:16:53 Running post build plugin 'Artifact Copier'  
31-Jan-2017 02:16:53 Finalising the build...  
31-Jan-2017 02:16:53 Stopping timer.

Could you please check, what I'm missing.