I am implementing a Powershell build script for teamcity to test some functionality, but cannot figure out out to report an error.
I am trying to follow this description:
https://confluence.jetbrains.com/display/TCD8/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-ReportingTests
However, although the script actually results in some tests being registered, it refuses to report errors. I am now back to the basic example from the . I have the following Powershell build step (error output: error, script: source):
Write-Host("##teamcity[testStarted name='className.testName']")
Write-Host("##teamcity[testStdErr name='className.testName' out='error text']")
Write-Host("##teamcity[testFinished name='className.testName']")
Resulting build log (verbose):
[13:27:12]Step 1/5: Output to build log (Powershell)
[13:27:13][Step 1/5] ##teamcity[buildStatisticValue key='buildStageDuration:firstStepPreparation' value='156.0']
[13:27:13][Step 1/5] ##teamcity[buildStatisticValue key='buildStageDuration:buildStepRUNNER_18' value='0.0']
[13:27:13][Step 1/5] Starting: C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -ExecutionPolicy ByPass -Command - < D:\JetBrains\buildagent\temp\buildTmp\powershell6640337654487221076.ps1
[13:27:13][Step 1/5] in directory: D:\JetBrains\buildagent\work\7e3fac8e390ca38d
[13:27:13][Step 1/5] className.testName
[13:27:13][className.testName] [Test Error Output] error text
[13:27:13][Step 1/5] Process exited with code 0
[13:27:13][Step 1/5] ##teamcity[buildStatisticValue key='buildStageDuration:buildStepRUNNER_18' value='536.0']
I.e. the test is registered in teamcity as executed bit it succeeds! I would expect the test to fail, due to the 'testStdErr' output! What it the correct way to make it fail?
Thanks,
Kim
You should use the testFailed directive which is listed on the page you linked:
##teamcity[testFailed name='MyTest.test1' message='failure message' details='message and stack trace']
Or change the build failure condition settings under 'Build Failure Conditions' to fail the build if you write to stderr (edit: this is my understand of the docs anyway):
Fail build if:
[ ] an error message is logged by build runner
Related
I try to use mlunitTest with ml-gradle 3.17.1 and Marklogic marklogic-unit-test-client:1.0.0
All the tests are OK, I test with my test user on the UI and with ml-gradle.
But when ml-gradle wants to access the results in a directory [build\test-results\marklogic-unit-test\TEST-{test-name}], java throws an error because the file isn't there.
Just before there is a comment who precises that it clears the directory.
Does anyone use the mlunitTest without this problem?
it's the same if i give the name of the result directory with the parameter : -PunitTestResultsPath=testML
Here are the traces of this part of execution :
Done running all suites; time: 82ms
4 tests completed, 0 failed
Deleted existing results directory: build\test-results\marklogic-unit-test
Releasing connection
:mlUnitTest (Thread[Execution worker for ':',5,main]) completed. Took 0.093 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':mlUnitTest'.
> java.nio.file.NoSuchFileException: build\test-results\marklogic-unit-test\TEST-historicId.xml
Try release 4.3.0 - it includes the following fix - https://github.com/marklogic-community/ml-gradle/issues/599
I am able to execute unit tests in the CLI using the following command:
/usr/local/Cellar/php#7.4/7.4.27/bin/php /Users/USERNAME/PhpstormProjects/PROJECT_FOLDER/vendor/phpunit/phpunit/phpunit /Users/USERNAME/PhpstormProjects/PROJECT_FOLDER/tests
However, i want to fire the tests from inside PhpStorm, but the IDE is automatically adding parameters to the executing command which causes an instant execute fail:
/usr/local/Cellar/php#7.4/7.4.27/bin/php /Users/USERNAME/PhpstormProjects/PROJECT_FOLDER/vendor/phpunit/phpunit/phpunit --configuration /Users/USERNAME/PhpstormProjects/PROJECT_FOLDER/phpunit.xml /Users/USERNAME/PhpstormProjects/PROJECT_FOLDER/tests --teamcity
Testing started at 11:51 ...
PHPUnit 9.5.10 by Sebastian Bergmann and contributors.
Unknown option "--configuration"
Process finished with exit code 1
When i disable the "Default configuration file" checkbox in Preferences > PHP > Test Frameworks > {current project config} - it says:
Unknown option "--no-configuration"
Process finished with exit code 1
Is there a way to disable the configuration parameter at all? I'm pretty new to unit tests and i don't even know which purpose this configuration file would even has...
I hope someone can help me - thanks in advance !!
I have a VSTS (Azure DevOps) build which contains a PowerShell or a Command line task. This task is running some program: program.exe. When program.exe returns a non-zero exit code, the build is failed as expected. program.exe also prints a detailed error message to the stderr stream in case of an error.
The problem is that the content of the stderr stream is not passed to the build. The task is always returning the following error message which is also displayed as a build failure message on the build summary tab:
Process completed with exit code 1.
Which is useless. The user has to look for a failed task, open its output and search for an error message there. That's not very convenient.
How to easily pass the content of stderr to the build?
Do I have to manually capture stderr and then send it to the build using PowerShell or is there a setting to change the build behaviour to work as I expect?
I just added "2>&1 | Write-Host" to the command so that the stderr stream will be routed to the Write-Host stream. Reference this thread: VSTS build fails with "Process completed with exit code 0 and had 3 error(s) written to the error stream." even though I set my PowerShell script to ignore errors
You can also try uncheck the Fail on Standard Error in your PowerShell script configuration and write the lastexitcode to pass the task:
Fail on Standard Error
If this is true, this task will fail if any errors are written to the
error pipeline, or if any data is written to the Standard Error
stream. Otherwise the task will rely solely on $LASTEXITCODE and the
exit code to determine failure.
Then you can output the error or warning by using PowerShell or VSTS task commands.
Write-Warning “warning”
Write-Error “error”
Write-Host " ##vso[task.logissue type=warning;]this is the waring"
Write-Host " ##vso[task.logissue type=error;sourcepath=consoleapp/main.cs;linenumber=1;columnnumber=1;code=100;]this is an error "
More information about the VSTS task command, you can refer to: Logging Commands
When i build a android app in ionic 3 it was build. but after using admobFree or admobPro plugin every time build failed and i get this error....
(Due to post limit i am posting last few lines of error)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 3m 22s
38 actionable tasks: 12 executed, 26 up-to-date
(node:11476) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cmd: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 3m 22s
[OK] Your app has been deployed.
Did you know you can live-reload changes from your app with --livereload?
C:\Users\SHEKH RAIES\Raies-Ionic\test\file-upload\upload>
I am late. but hope this might help developers searching for an answer. I have gone through a lot to fix this issue. documentation didn't help. changing the configuration didn't do anything. removing and readding platform didn't help. etc
Here is how I fixed this.
open file
project-folder/plugins/cordova-admob-sdk/plugin.xml
check this part
<platform name="android">
<preference name="PLAY_SERVICES_VERSION" default="11.0"/>
<framework src="com.google.android.gms:play-services-base:$PLAY_SERVICES_VERSION" />
<framework src="com.google.android.gms:play-services-ads:$PLAY_SERVICES_VERSION" />
</platform>
see file project-folder/platforms/android/build.gradle ( this file changes each time when project is build)
this dependencies part
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
implementation(project(path: "CordovaLib"))
compile "com.android.support:appcompat-v7:23+"
compile "com.google.android.gms:play-services-base:11.0"
compile "com.google.android.gms:play-services-ads:11.0"
compile "com.google.android.gms:play-services-analytics:+"
compile "com.android.support:support-v4:27.+"
// SUB-PROJECT DEPENDENCIES END
}
see another file project-folder/platforms/android/project.properties
target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.android.support:appcompat-v7:23+
cordova.gradle.include.1=com.synconset.imagepicker/odi-ignorelinterrors.gradle
cordova.gradle.include.2=com.synconset.imagepicker/odi-androidtarget.gradle
cordova.system.library.2=com.google.android.gms:play-services-base:11.0
cordova.system.library.3=com.google.android.gms:play-services-ads:11.0
cordova.system.library.4=com.google.android.gms:play-services-analytics:+
cordova.gradle.include.3=phonegap-plugin-barcodescanner/odi-barcodescanner.gradle
cordova.system.library.5=com.android.support:support-v4:27.+
How i fixed
1 - changed file
project-folder/plugins/cordova-admob-sdk/plugin.xml
from 11.0 to + so it would look like this
<platform name="android">
<preference name="PLAY_SERVICES_VERSION" default="+"/>
<framework src="com.google.android.gms:play-services-base:$PLAY_SERVICES_VERSION" />
<framework src="com.google.android.gms:play-services-ads:$PLAY_SERVICES_VERSION" />
</platform>
2 - build (sudo ionic cordova build android)
that's it.
After building see file project-folder/platforms/android/build.gradle
the dependencies part. looks like this
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
implementation(project(path: "CordovaLib"))
compile "com.android.support:appcompat-v7:23+"
compile "com.google.android.gms:play-services-base:11.0"
compile "com.google.android.gms:play-services-ads:11.0"
compile "com.google.android.gms:play-services-analytics:+"
compile "com.android.support:support-v4:27.+"
// SUB-PROJECT DEPENDENCIES END
}
and project-folder/platforms/android/project.properties looks like this
target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.android.support:appcompat-v7:23+
cordova.gradle.include.1=com.synconset.imagepicker/odi-ignorelinterrors.gradle
cordova.gradle.include.2=com.synconset.imagepicker/odi-androidtarget.gradle
cordova.system.library.2=com.google.android.gms:play-services-base:+
cordova.system.library.3=com.google.android.gms:play-services-ads:+
cordova.system.library.4=com.google.android.gms:play-services-analytics:+
cordova.gradle.include.3=phonegap-plugin-barcodescanner/odi-barcodescanner.gradle
cordova.system.library.5=com.android.support:support-v4:27.+
I have a strange problem,
my MSBuild runs tests, code-coverage and publishing fine (part of the build.txt shown):
Results Top Level Tests
------- ---------------
Passed BuildTestProject.UnitTest1.TestMethod1
Passed BuildTestProject.UnitTest1.TestMethod2
2/2 test(s) Passed
...
Results file: W:\BuildWorkspace\XXX\Test Release\TestResults\XXX_XXX 2009-08-20 11_47_09_Any CPU_Release.trx
Run Configuration: Local Test Run
Waiting to publish...
Publishing results of test run XXX#XXX 2009-08-20 11:47:09_Any CPU_Release to http://XXX:8080/Build/v1.0/PublishTestResultsBuildService2.asmx...
....Publish completed successfully.
When I import these testresults on my local machine i get to see the code coverage-data as expected. But the code-coverage details are not shown in the details of the build that Visual Studio shows when you expand the 'results details'.
Any tips?
Finally found the solution today, found out that my TeamFoundationServer itself had problems with publishing the results to my buildAgent. I read somewhere (after searching for CoverAn.exe) that it is installed as a service, then i checked the credentials for the service 'Code Coverage Analysis Service'.
These were running under TFSMachine\NETWORK instead of our service-account for the TeamFoundationServer. Changed this, reran a build with tests in it and it now publishes the results.
W00t!
Check that the .testrunconfig used by the server has coverage enabled. It may be different than your local .testrunconfig.