How to save MS Test's result in a Jenkins variable? - jenkins

One of my Jenkins job is executing MSTest. I am passing the following command to
Execute Windows batch command:
del TestResults.trx
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\MSTest.exe" /testcontainer:D:\Projects\Jenkins\TestResultVerificationFromJenkins\TestResultVerificationFromJenkins\bin\Debug\TestResultVerificationFromJenkins.dll /resultsfile:TestResults.trx /nologo /detail:stdout
At the time of execution, Console Output is displaying the following values:
Starting execution...
Results Top Level Tests
------- ---------------
Passed TestResultVerificationFromJenkins.UnitTest1.PassTest
[stdout] = Test is passed*
1/1 test(s) Passed
Summary
Test Run Completed.
Passed 1
Total 1
Results file: C:\Program Files (x86)\Jenkins\jobs\JenkinsTestResultReader\workspace\TestResults.trx
Test Settings: Default Test Settings
In the post build step, I have to pass the MS test result "Test is passed" to a HTTP Request.
Is there any way to save this result in a Jenkins variable so that I can pass that to HTTP Request?
Regards,
Umesh

Since you are in the postbuild step, would parsing the console output for the test result and sending it off to the HTTP Request be an option for you?
For example, using Groovy Postbuild plugin, you could write a small script that could do this.
Perhaps something like:
if(manager.build.logFile.text.indexOf("Test Run Completed. Passed") >= 0)
manager.listener.logger.println (new URL("http://localhost?parameter=Test+is+passed")).getText()

Related

How to get SoapUi assertion result back in jenkins script

In my Jenkins file, i am executing maven command and it is executing very well.
mvn com.smartbear.soapui:soapui-maven-plugin:5.5.0:test -f src/main/resources/testcases/pom.xml
I can see reports generated and in Jenkins log i can see status of test execution.
SoapUI 5.3.0 TestCaseRunner Summary
Time Taken: 3922ms
Total TestSuites: 1
Total TestCases: 1 (0 failed)
Total TestSteps: 1
Total Request Assertions: 3
Total Failed Assertions: 0
Total Exported Results: 1
what i want is to get the status of test execution, like success or failure, how can i get test execution result back in Jenkins file so i can add stage as success of failure.

Jenkins Job not execute Protractor tests good

I have Protractor tests, and I run tests with command tests with protractor protractor.conf.js --suite full in VS code on my local. VS code run chrome instance and executed tests well.
After that I setup Jenkins job for Protractor tests. My steps:
Pull code form BitBucket
Execute windows command npm install
Executed windows command node_modules\.bin\ng e2e --webdriver-update
Jenkins opened chrome browser on http://localhost:49156/ ** and start with Protractor tests.
On Chrome browser my tests could to find element by ID,HTML,text, but when needed to click on element I have this error [31m- [39m[31mFailed: element not interactable.
This is piece of console output:
[15:37:51] W/element - more than one element found for locator by.buttonText("Create") - the first result will be used
Creating configuration for
[31m× Creating default configuration [39m
[31m- [39m[31mFailed: element not interactable
(Session info: chrome=69.0.3497.100)
(Driver info: chromedriver=2.42.591088 (7b2b2dca23cca0862f674758c9a3933e685c27d5),platform=Windows NT 6.2.9200 x86_64)[39m
(Session info: chrome=69.0.3497.100)
(Driver info: chromedriver=2.42.591088 (7b2b2dca23cca0862f674758c9a3933e685c27d5),platform=Windows NT 6.2.9200 x86_64)
at Object.checkLegacyResponse (C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\selenium-webdriver\lib\error.js:546:15)
at parseHttpResponse (C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\selenium-webdriver\lib\http.js:441:30)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
From: Task: WebElement.click()
This is the Protractor tests:
it('Creating default configuration 2000 ', () => {
_home.get2000Configuration().click();
_descriptionModal.buttonStartCreate().click();
for (let i = 0; i < 4; i++) {
_wizardModal.buttonNext().click();
}
_descriptionModal.buttonCreate().click();
expect(_configurationView.getBaImage().isDisplayed()).toBe(true).then(function (result) {
expect(_configurationView.getNeb().count()).toBe(2);
expect(_configurationView.getmage().count()).toBe(2);
expect(_configurationView.getEngineImage().isDisplayed()).toBe(true);
});
});
Checking the error stack that you posted I can see this:
[15:37:51] W/element - more than one element found for locator by.buttonText("Create") - the first result will be used
My guess is that has more than one button with this "Create" text and your code is getting lost. I would suggest check upon the button names and make sure that only one has this "Create" label, for example.

Called by Open Cover, Nunit Runner Console throws NullReferenceException and hangs forever

In my project, I use Nunit 2 framework.
In the build server, I use Open Cover 4.6.519 to analyze the code coverage with the following command:
"OpenCover.4.6.519\OpenCover.Console.exe"
-target:"..\..\Packages\NUnit.Runners.2.6.4\tools\nunit-console-x86.exe"
-targetargs:"/nologo /framework:net-4.0 /process:multiple /domain:multiple /noshadow /nothread <the_list_of_test_assemblies>"
-filter:"+[*]* -[*.Test]* -[*.Stub]* -[Deedle]* -[FSharp]*" -hideskipped:Filter -register -output:Build\OpenCoverResult.xml`
This is the result I get:
Executing: D:\Jenkins\workspace\SC Nightly\Packages\NUnit.Runners.2.6.4\tools\nunit-console-x86.exe
ProcessModel: Multiple DomainUsage: Multiple
Execution Runtime: net-4.0
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at NUnit.Core.ProxyTestRunner.CountTestCases(ITestFilter filter)
at NUnit.Util.AggregatingTestRunner.CountTestCases(ITestFilter filter)
at NUnit.Util.AggregatingTestRunner.Run(EventListener listener, ITestFilter filter, Boolean tracing, LoggingThreshold logLevel)
at NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options)
at NUnit.ConsoleRunner.Runner.Main(String[] args)
Committing...
Visited Classes 0 of 617 (0)
Visited Methods 0 of 4030 (0)
Visited Points 0 of 11734 (0)
Visited Branches 0 of 6814 (0)
==== Alternative Results (includes all methods including those without corresponding source) ====
Alternative Visited Classes 0 of 671 (0)
Alternative Visited Methods 0 of 4663 (0)
I see an null reference exception thrown by Nunit runner, but it seems that OpenCover hangs after Nunit runner stopped.
I am thinking of some potential reasons:
The amount of test assemblies is large (59 dll files)
The assemblies are built in .Net Framework 4.5, but the framework argument of Nunit runner is net-4.0
I am using Nunit 2 which is out of date. (It is very expensive for me to upgrade to Nunit 3)
There might be something wrong with my Jenkins. I use Jenkins to run an .msbuildproj file which containing a task to execute OpenCover. When I run OpenCover command on Windows Command Prompt, it works well.

Integrate Specs2 results with Jenkins

I want to integrate the Specs2 test results with Jenkins.
I was added the below properties in sbt:
resolver:
"maven specs2" at "http://mvnrepository.com/artifact"
libraryDependencies:
"org.specs2" %% "specs2" % "2.0-RC1" % "test",
System Property:
testOptions in Test += Tests.Setup(() => System.setProperty("specs2.outDir", "/target/specs2-reports")) //Option1
//testOptions in Test += Tests.Setup(() => System.setProperty("specs2.junit.outDir", "/target/specs2-reports")) //Option2
testOptions in Test += Tests.Argument(TestFrameworks.Specs2, "console", "junitxml")
If I run the below command, it is not generating any specs reports in the above mentioned directory("/target/specs2-reports").
sbt> test
If I run the below command, it is asking for the directory as shown in the below error message:
sbt> test-only -- junitxml
[error] Could not run test code.model.UserSpec: java.lang.IllegalArgumentException: junitxml requires directory to be specified, example: junitxml(directory="xxx")
And it is working only if I give the directory as shown below:
sbt> test-only -- junitxml(directory="\target\specs-reports")
But sometimes its not generating all the specs report xmls (some times generating only one report, sometimes only two reports etc.).
If I give test-only -- junitxml(directory="\target\specs-reports") in the jenkins it is giving the below error.
[error] Not a valid key: junitxml (similar: ivy-xml)
[error] junitxml(
[error] ^
My main goal is, I want to generate the consolidated test reports in junit xml format and integrate with Jenkins. Kindly help me to solve my problem.
Best Regards,
Hari
The option for the junitxml output directory is: "specs2.junit.outDir" and the default value is "target/test-reports".
So if you don't change anything you could just instruct Jenkins to grab the xml files from "target/test-reports" which is what I usually do.
Also you might have to enclose your sbt commands in Jenkins with quotes. This is what I typically do:
"test-only -- html junitxml console"

CVS error - CVS exited with error code 1

I am seeing this error for quite sometime now.
I am running ant build on CYGWIN which inturn runs on WindowsXP.
The resolution(bad one) I found was to delete my gcct/first directory and run ant build again (which runs from another directory). It runs successfully but if I modify some code under gcct/first, I do not want to delete it because of this error.
I did see this link. The resolution here does not apply to me since I do not have .cvspass defined anywhere in the build.xml.
C:\svn\CEL_v3681\buildCore.xml:1883: cvs exited with error code 1
Command line was [Executing 'cvs' with arguments:
'checkout'
'-A'
'-rfirst_v2_126'
'gcct/first'
The ' characters around the executable and arguments are
not part of the command.
environment:
ALLUSERSPROFILE=C:\Documents and Settings\All Users
ANT_HOME=C:/Apps/Apache/apache-ant-1.7.0
APPDATA=C:\Documents and Settings\shankarc\Application Data
CLASSPATH=./;C:/Program Files/Java/jre1.5.0_07/lib/ext/QTJava.zip
COMMONPROGRAMFILES=C:\Program Files\Common Files
COMPUTERNAME=NYKPWM2035798
COMSPEC=C:\WINNT\system32\cmd.exe
CUSTPROF=Roaming700Live
CVSROOT=:pserver:shankarc#amcvs2.lehman.com:/home/eqcvs/cmte
CVS_RSH=/bin/ssh
FP_NO_HOST_CHECK=NO
HOME=C:\Apps\CYGWIN\home\shankarc
HOMEDRIVE=F:
HOMEPATH=\
HOSTNAME=nykpwm2035798
IDEA_PROPERTIES=C:\Documents and Settings\shankarc\idea.properties
INFOPATH=/usr/local/info:/usr/share/info:/usr/info:
JAVA_HOME=C:/Program Files/Java/jdk1.6.0_21/
JDK_HOME=C:\Program Files\Java\jdk1.6.0_21\
LOGONSERVER=\\NYKPSM00069
MANPATH=/usr/local/man:/usr/share/man:/usr/man::/usr/ssl/man
NUMBER_OF_PROCESSORS=2
OS=Windows_NT
PATH=C:\Apps\CYGWIN\usr\local\bin;C:\Apps\CYGWIN\bin;C:\Apps\CYGWIN\bin;C:\Apps\CYGWIN\usr\X11R6\bin;C:\Apps\Apache\apache-ant-1.7.0\bin;C:\Program Files\Java\jdk1.6.0_21\bin\;C:\Apps\CYGWIN\bin;C:\Program Files\VisualSVN Server\bin;C:\Program Files\Sudowin\Clients\Console;C:\Program Files\Fortify Software\Fortify 360 v2.5.0\bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.PSC1
PRINTER=\\NYKPSM04020\NYKLPR1301-03-03C05
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 6, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=0f06
PROFGROUP=FONP
PROGRAMFILES=C:\Program Files
PROMPT=$P$G
PWD=/cygdrive/c/svn/CEL_v3681/gcct/cel
QHOME=c:\q
QTJAVA=C:\Program Files\Java\jre1.5.0_07\lib\ext\QTJava.zip
SESSIONNAME=Console
SHLVL=1
SITECODE=NYK
SITEIDENT=NYK
SVN_ASP_DOT_NET_HACK=1
SYSTEMDRIVE=C:
SYSTEMROOT=C:\WINNT
TEMP=C:\TEMP
TERM=cygwin
TMP=C:\TEMP
UATDATA=C:\WINNT\system32\CCM\UATData\D9F8C395-CAB8-491d-B8AC-179A1FE1BE77
USER=shankarc
USERDNSDOMAIN=INTRANET.BARCAPINT.COM
USERDOMAIN=INTRANET
USERNAME=shankarc
USERPROFILE=C:\Documents and Settings\shankarc
WINDIR=C:\WINNT
CVS_PASSFILE=C:\Apps\CYGWIN\home\shankarc\.cvspass]
Total time: 58 seconds
How I resolve this?
I had the same issue and found that even though I was not using .cvspass I did have a build property of cvs.pass set which needed to be reset to OVERRIDE to function depending on how you set up your cvs access (though it looked similar from your post). This needed to be changed in build.properties and .build.properties. Hope this helps!

Resources