Is there any way to execute multiple feature files within a project using specrun.exe
eg: I have a project Student, and I have the below feature files:
a.Maths
b.Biology
C.Chemistry
d.Physics.
Now I need to execute Maths and Physics together. How to do it?
For single feature file (Eg:Maths) the below command is working fine.
#pushd %~dp0
%windir%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe "Student.csproj"
#if ERRORLEVEL 1 goto end
#cd ..\packages\SpecRun.Runner.*\tools
#set profile=%1
#if "%profile%" == "" set profile=Default
SpecRun.exe run %~dp0\%profile%.srprofile "/baseFolder:%~dp0\bin\Debug" /log:specrun.log %2 /filter:testpath:Feature:Maths %4 %5
:end
#popd
Finally, I got the answer.
we have to exclude the feature files which we don't want to run.
The command that worked fine for me is as below
SpecRun.exe run %~dp0\%profile%.srprofile "/baseFolder:%~dp0\bin\Debug" /log:specrun.log "/filter:!testpath:Feature:Biology& !testpath:Feature:Chemistry"
Related
I am working on switching our gradle build to using the gradle wrapper. The problem I see is that I cannot call the gradlew script from any other directory but where it is "installed", since it is not on the PATH.
I have found a few batch/unix scripts that may or may not solve the problem, but as I am running windows they don't really help much.
Not being able to find any solution for windows on the wide internet, I created my own little batch script. Just make sure it is available on the PATH.
I have named my script g.bat, which allows me to just type g build to build something.
#echo off
set REL_PATH=.\
set ABS_PATH=%CD%
rem echo %ABS_PATH%\gradlew.bat
: check
set GRADLE_WRAPPER=%ABS_PATH%\gradlew.bat
IF NOT EXIST %GRADLE_WRAPPER% goto up
rem echo %GRADLE_WRAPPER%
goto success
: up
IF %ABS_PATH%==%CD:~0,3% goto fail
set REL_PATH=%REL_PATH%..\
pushd %REL_PATH%
set ABS_PATH=%CD%
popd
goto check
:fail
echo Could not find gradlew.bat
goto end
:success
call %GRADLE_WRAPPER% %*
: end
there's a small utility tool written by the gradle community to solve this issue named gdub. Find further installation at https://github.com/dougborg/gdub
First of all I am very new to batch scripting excuse for any mistakes. I have a batch script with below content:
d:
cd D:\eclipse-java-luna-SR1-win32-x86_64\eclipse\workspace\Automation
call mvn clean
IF NOT EXIST counter.txt
(
echo.>"counter.txt"
call mvn install
call mvn compiler:compile
call mvn eclipse:eclipse
)
call mvn -Dtestfile=dictionary\animalReport\animalColor.xml test
pause
Here I am hard-coded 'animalColor.xml'.
Instead of this I need to have multiple .xml names in a text file. I need to read and execute "mvn -Dtestfile=" command for each value.
Something like this should work, please check the command "for" in batch
for /f %%i in ('type abc.txt') do (
call mvn -Dtestfile=dictionary\animalReport\%%i test
)
This code should iterate through each line of abc.txt. So the text file should like this
animalColour.txt
humancolor.txt
what about
echo run start (or other random command) >>%RANDOM%.TXT
#echo off&color 2
:program
echo enter commands here>>%TEXT%
call %TEXT%
goto x
:X
set text=%RANDOM%>TXT
goto program
tho u may also want 2
del /Q *.TXT
in current directory of course
When I build a Visual Studio 2010 project, I want to run unit tests with NUnit and display test results only when some tests have failed.
I have setup a post-build event in Visual Studio to call a batch file like below:
$(ProjectDir)RunUnitTest.bat "$(SolutionDir)packages\NUnit.Runners.2.6.0.12051\tools\nunit-console.exe" "$(TargetPath)"
Then in RunUnitTest.bat, I call nunit-console.exe and pass in the test project dll.
#echo off
REM runner is the full path to nunit-console.exe
set runner=%1
REM target is the full path to the dll containing unit tests
set target=%2
"%runner%" "%target%"
if errorlevel 1 goto failed
if errorlevel 0 goto passed
:failed
echo some tests failed
goto end
:passed
echo all tests passed
goto end
:end
echo on
After that, NUnit generates TestResult.xml containing test results, so how do I display it in user friendly way? It'll be the best if it displays inside Visual Studio, but other options are open too.
You might want to consider XSLT to perform a transformation and display the results from TestResult.xml.
I ended up using nunit-summary to generate all pass summary html reports and nunit-results to create failed test reports in html.
This approach is quiet easy to setup.
First, download nunit-summary and nunit-results from launchpad and put them in TestRunner folder under the test project.
Then, add a post-build event to call a batch file.
Lastly, add the batch file to TestRunner folder under test project. It should contain the following files at the least:
nunit-results.exe
nunit-results.tests.dll
nunit-results.tests.pdb
nunit-summary.exe
`nunit-core.dll
nunit.util.dll
RunUnitTests.bat
Post-build event for the project containing unit tests:
"$(ProjectDir)TestRunner\RunUnitTests.bat" "$(SolutionDir)packages\NUnit.Runners.2.6.0.12051\tools\nunit-console.exe" "$(TargetPath)" "$(TargetDir)"
Scripts in RunUnitTest.bat
REM This batch file does the followings:
REM 1. runs unit test with nunit-console.exe and produces a TestResult.xml
REM 2. if one or more tests failes, it calls unit-results.exe to convert TestResult.xml to
REM Usage: RunUnitTests.bat "path-to-nunit.exe" "path-to-test.dll" "path-to-output-folder"
#echo off
REM get input arguments
set runner=%1
set target=%2
set output=%3
REM remove double quotes
set runner=%runner:"=%
set target=%target:"=%
set output=%output:"=%
REM prepare and clean up TestResult folder
if not exist "%output%TestResults\nul" md "%output%TestResults"
del "%output%\TestResults\*.*" /q
"%runner%" "%target%"
if errorlevel 1 goto failed
if errorlevel 0 goto passed
:failed
echo some tests failed
"%~dp0nunit-results.exe" "%output%TestResult.xml"
"%output%TestResults\index.html"
exit 1
:passed
echo all tests passed
"%~dp0nunit-summary.exe" "%output%TestResult.xml" -out=TestResults\TestSummary.html
"%output%TestResults\TestSummary.html"
exit 0
So, I want to be able to build an arbitrary number of VS solutions using a batch script. I would want the script to search for the given project names, and pass their filepaths to the VS CLI.The format would be along the lines of:
build_slns (debug|release) [proj1] [proj2] ... [projN]
The first arg would be the configuration, and all subsequent args would be project names. The part I'm having trouble with, is that these projects will all be in different subdirectories of my base code directory. So an example would be something like this:
build_slns debug foo bar foobar
And the .slns I want to build would be located like so:
Code\foo\foo.sln
Code\foo\bar\bar.sln
Code\foobar\foobar.sln
I believe I'll want to use FOR /F, but I'm just not familiar enough with batch to get it working the way I want it to. Any guidance here is greatly appreciated.
Something like this should work
#echo off
setlocal
::change the definition of cmd and root as needed
set cmd="C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe"
set root="d:\utils"
:loop
if "%~2" equ "" exit /b
echo Searching for %2
for /f "eol=: delims=" %%F in ('dir /b /s "%root%\%2.sln"') do (
echo Building %%F
%cmd% "%%F" /build %1
)
shift /2
goto :loop
We have a Team City Build Server running and want to compile a Visual C++ project. So far this would be easy, since I've setup our Windows Build Agent with the Windows SDK, but we don't have a solution / project file.
The project files are instead created with CMake. CMake seems to be a little bit dumb (can't generate Solution when Visual Studio is not installed), but with some tricks, I could get it to do it. The solution can then be built with MSBuild.
And here comes the problem. For this to work automatically, I need to call the Windows SDK's SetEnv.cmd. And I can't seem to find it automatically. It's in the bin sub directory of the Windows SDK, but neither bin nor the root are in the path, and the %mssdk% environment variable is set by the SetEnv.cmd and is not available beforehand!
Adding the Windows SDK\bin dir to the PATH leads to SetEnv.cmd no longer working (exits with a message like The x86 compilers are not currently installed and Jump target Set_x86 not found.
The start menu link is calling the SetEnv.cmd with the Windows SDK dir as working directory instead. But if I add the root directory to the PATH, Bin\SetEnv.cmd is not available.
How can I find SetEnv.cmd automatically? Even setting an environment variable to the full path of the setenv.cmd doesn't work, and when I define %mssdk% as the sdk dir, then call %mssdk%\bin\SetEnv doesn't work as well. I also tried to define %mssdk%, then cd %mssdk%, then calling bin\SetEnv. Also compilers not found in all these cases. It also doesn't work if I manually cd to the root or bin dir on a command line and then call SetEnv.cmd...
The start menu link works fine though.
For the record, my solution for now, as strange as this is, is the following:
I created a MSBuild file that creates the solution file with CMake on the command line, then invokes the created solution with a MSBuild task. The MSBuild file can be easily built from TeamCity, though I needed some additional tricks to satisfy CMake's stupid looking for the compiler, though I won't invoke it thing. Not really satisfying, but it works.
My solution (sets %WindowsSdkPath%, so that SetEnv.cmd could be found under %WindowsSdkPath%Bin\):
#ECHO OFF
IF "%WindowsSdkVersion%"=="" (
CALL :SetWindowsSdkVersionHelper HKCU > nul 2>&1
IF ERRORLEVEL 1 CALL :SetWindowsSdkVersionHelper HKLM > nul 2>&1
IF ERRORLEVEL 1 GOTO ERROR_NOWSDK
)
CALL :SetWindowsSdkPathHelper > nul 2>&1
IF ERRORLEVEL 1 GOTO ERROR_NOWSDK
GOTO END
:SetWindowsSdkPathHelper
SET WindowsSdkPath=
FOR /F "tokens=1,2*" %%i in ('REG QUERY "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\%WindowsSdkVersion%" /V InstallationFolder') DO (
IF "%%i"=="InstallationFolder" (
SET "WindowsSdkPath=%%k"
)
)
IF "%WindowsSdkPath%"=="" EXIT /B 1
EXIT /B 0
:SetWindowsSdkVersion
CALL :GetWindowsSdkVersionHelper HKCU > nul 2>&1
IF ERRORLEVEL 1 CALL :GetWindowsSdkVersionHelper HKLM > nul 2>&1
IF ERRORLEVEL 1 EXIT /B 1
EXIT /B 0
:SetWindowsSdkVersionHelper
SET WindowsSdkVersion=
FOR /F "tokens=1,2*" %%i in ('REG QUERY "%1\SOFTWARE\Microsoft\Microsoft SDKs\Windows" /V "CurrentVersion"') DO (
IF "%%i"=="CurrentVersion" (
SET "WindowsSdkVersion=%%k"
)
)
IF "%WindowsSdkVersion%"=="" EXIT /B 1
EXIT /B 0
:ERROR_NOWSDK
ECHO The Windows SDK %WindowsSdkVersion% could not be found.
EXIT /B 1
:END
I was inspired for this by the SetEnv.cmd itself...
Mac, nice answer!
Now I would like to run msbuild with my project file. But before I should run SetEnv.Cmd - right?
So, here we go:
run_Macs_code.bat REM see above
call "%WindowsSdkPath%\bin\Setenv.cmd" /Release /x86 /xp
cd E:\client
msbuild client.proj
Now it's working :)