Jenkins vstest runner - no files matching the pattern - jenkins

I am new to Jenkins and trying to run some unit test for a sql database using VS Test Runner plugin each time I am getting the response "no files matching the pattern [full file path]/Unit_tests.dll".
I have tried running the tests in command line by running:
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" [full file path]/Unit_tests.dll
and this executes the tests successfully. I am passing the same arguments I am passing into the jenkins plugins which returns "no files matching the pattern" message?
can anyone advise what I am doing wrong or need to do to get it to work

It seems work after set the vstestrunner path with double quote and execution name.

Related

Jenkins TestNG plugin does not fetch results from the test-results.xml file

In my project workspace, the test-results.xml file exists inside the target\surefire-reports\testng-results.xml directory. But Jenkins fails to read the XML file and gives below error on console.
TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern: **\target\surefire-reports\testng-results.xml
Did not find any matching files.
To ensure the file isn't too old, I had checked that the test-results.xml (and other files) belong to the latest test run. The Jenkins server is running on Ubuntu 14.04 LTS.
I'm running my tests in this manner: My project root directory has a run_tests.sh script which looks like this:
#!/bin/bash
if [ "$1" = "" ]; then
echo "Please provide a valid suite XML file name."
else
mvn clean
mvn compile
mvn clean test -Dsurefire.suiteXmlFiles="$1"
fi
I just pass the suite XML file name as a parameter to this script in Jenkins (execute shell).
Please help.
I found the solution for this.
Go to Configure of your Job
in General Tab, you may find
Advanced Button, Click on this
Check the check box of "Use custom
workspace", under this you see the Directory text box, here you copy
your Selenium Workspace Folder, for example mine is
"E:\eclipse\eclipse-workspace\WebDriveTest\"
Scroll down the page
under the Post-build Actions, Publish TestNG Results, TestNG XML
report pattern : give like this
"**/target/surefire-reports/testng-results.xml" (check this path in
the same workspace).
I hope this will help you!.
You should be using / instead of \ (since you mentioned that your Jenkins is running on a UNIX box)
Krishnan, in the testng-users Google Group, pointed out that it could be an issue with my Jenkins project workspace, and it was the same.
I changed the default workspace in my Jenkins project.
So I've added the path "$HOME/myWorkspace/myProject/" in my Jenkins project workspace, and "**/target/surefire-reports/testng-results.xml" in my TestNG setting in the same Jenkins project, and it works!
Thank you Krishan for your help.
Please see my answer in another post here, it should be very clear.
In short, it is caused by the current directory was changed to the default Jenkins workspace, you need set your custom workspace in the Job's Config.
I agree with Krishnan Mahadevan usage of '\' instead of '/' while providing the path for TestNG Report also solved my problem.
Extremely important thing to note here:
When providing path for Root POM in the build section '\' is used
C:\Users\harsh\eclipse-workspace\ProjTwo3\pom.xml
When providing path for TestNG XML report pattern in Publish TestNG Result section
'/' is used
C:/Users/harsh/eclipse-workspace/ProjTwo3/target/surefire-reports/testng-results.xml
Console Output:
channel stopped
TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern:
C:/Users/harsh/eclipse-workspace/ProjTwo3/target/surefire-reports/testng-results.xml
Saving reports...
Processing 'C:\Users\harsh.jenkins\jobs\MyApplication\builds\12\testng\testng-results.xml'
11.688312% of tests failed, which exceeded threshold of 0%. Marking build as UNSTABLE

Include Build number in Jenkins test result file

I have a test project in Jenkins. And each time I build my project it says.
The results file "My File Path" already exists. Please specify a
different results file or verify the existing file is no longer needed
and delete it.
So I've decided to include the build number in the name of my result file.
And I'm using my result file to generate some graphical output also.
How can I include my Build Number in both locations
This is the windows batch command execution
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\mstest.exe"
/testcontainer:"%WORKSPACE%\TestAutomation\bin\debug\TestAutomation.dll"
/resultsfile:"%WORKSPACE%\results.xml"
And I'm using my result file as follows.
How can I change both these locations to add current build number in my result file as followingformat
result_BuildNumber.xml
Try this,
result_%BUILD_NUMBER%.xml - for batch
result_$BUILD_NUMBER.xml - for shell
BUILD_NUMBER is environment variable.

NUnit tests with TFS 2013

I'm trying to get TFS to run my unit tests.
The name of the project assembly is Users.SystemTests.dll. It's located in ~/source/Users.SystemTests/bin/debug. The solution file is located in ~/source/Users.sln.
I've included the Nunit.VisualStudio.TestAdapter nuget package the in test assembly project.
The results of the build shows that the tests don't run.
What am I missing? They run fine locally via the Resharper test runner and I can also use nunit-console-x86.exe to run them.
Does this have something to do with the fact that I'm building a solution file? Maybe it's the output location being "AsConfigured?"
Ok, so I tracked this down on my own. It was twofold. The first problem was the the TestAdapter was not being output to the bin directory. The other piece was the Output Location. Setting copy local and then Output Location SingleFolder fixed the issue.
I do believe this is a bug in the tfs build. It works when you use SingleFolder or PerProject, but not AsConfigured. In the latter case the test runner don't find the testassemblies, and this is the same for both NUnit and MSTest, so it is not adapter specific.
The diagnostics log says:
Run VS Test Runner00:00:00
There were no matches for the search pattern C:\a\bin\**\*test*.dll
There were no matches for the search pattern C:\a\bin\**\*test*.appx

Jenkins + NUnit with TFS on Build Server

I'm new to continuous integration. I'm trying to get Jenkins to execute unit tests from a TFS project. My Jenkins build (pre-NUnit build step) is successful and I've installed the NUnit Jenkins plugin and I've read this post, but it's failing with this error: "The system cannot find the path specified."
I think the trouble is that I'm NOT running from my local machine, so the test DLL that NUnit should be running is missing I think. How can I reference that DLL properly? Do I need an extra Build Step to copy the files or something? Here's my "Execute Windows Batch Command" build step command:
"C:\Program Files\NUnit 2.6.3\bin\nunit-console.exe Victoria.Tests.Integration/bin/Debug/Victoria.Tests.Integration.dll /xml=nunit-result.xml"
The problem is that your command is all in quotes, including the parameters.
Change
"C:\Program Files\NUnit 2.6.3\bin\nunit-console.exe Victoria.Tests.Integration/bin/Debug/Victoria.Tests.Integration.dll /xml=nunit-result.xml"
to
"C:\Program Files\NUnit 2.6.3\bin\nunit-console.exe" Victoria.Tests.Integration/bin/Debug/Victoria.Tests.Integration.dll /xml=nunit-result.xml

Jenkin's Nunit plugin not expanding environment variables?

I have a nunit result located at the following location:
jobs\Nunit test\Main\nunit-result.xml
I specify this location in Nunit plugin field, in Post-build step i.e Publish Nunit-test Result report. This works fine and the builds shows Nunit graph.
The problem that i am getting is when i change the path to:
jobs\Nunit test\${branchName}\nunit-result.xml
I get the following
error: FATAL: No NUnit test report files were found. Configuration error?
branchName=Main
is specified by using EnvInject plugin. This variable is accessible in HTML publisher plugin where i specify the path of html.
I have searched a lot and i am guessing that the environment variables are not being expanded in the path.
Jenkins Version= 1.546, Nunit plugin Version = 0.15
Kindly help me in this problem.
The NUnit plugin doesn't work well with spaces. Try
jobs\Nunit_test\$branchName\nunit-result.xml
Jenkins NUnit plugin only allows to specify XML file paths in "Ant glob syntax". Hence, when you echo your path containing an environment variable, you are able to see it recognizing the environment variable properly, while NUnit plugin does not interpret it the same way.

Resources