How to run multiple SpecFlow scenarios using batch script? - batch-file

I have visual studio 2015 professional edition and in my project there are many feature files and they contain several scenarios of specflow.
I want to run some specific scenarios(having same tag name) of different features using a batch script. So, How do i do that?

It depends which test runner you are using and which flavour Specflow generates your tests in. Basically you write a batch script to call a console tool of your test runner to run the tests. Assuming you are using NUnit you can run them with NUnits runner as described in the documentation other runners will require other stuff

I got the solution, to run specific scenarios we will use common tag name for those scenarios and use the tag in the batch file.
Ex: Features /include:
And after that we use the tag on another batch file(Ex: set arg1=%1). There you initialize the variable for the project. Set the packages for the project and debugger-location.
Then use it in the nunit console and run the .dll file
Ex: nunit-console "%DebuggerLocation%\%Namespace%.dll" %arg1%

Related

Using TF command-line get latest, how do I run SonarQube analysis only if new code has been checked-in?

I use a BAT file to run TF command-line get latest and then call the Sonar runner BAT file to run analysis on the latest code.
I have automated this every hour using Task Scheduler.
I want to run Sonar analysis only if TF gets new code, else it should skip.
How do I achieve this? I tried searching for exit codes, but nothing tells me if any new code was fetched.
Visual Studio Team Services or TFS 2015+
You can configure a build to be triggered on Continuous Integration (CI), i.e. whenever changes are made, the build is triggered. A build can be whatever you want, from invoking a proper msbuild / mstest and SonarQube task or doing your own stuff using cmd / powershell / bash.
To learn more about integrating SonarQube analysis with TFS Build see: https://blogs.msdn.microsoft.com/visualstudioalm/2015/08/24/build-tasks-for-sonarqube-analysis/
TFS 2013
You can configure a XAML build to run on Continous Integration
Through scripts
Continous Integration builds are the recommended way of running logic when a change happens in your code. However, if you'd like to use "tf get" - you could capture the output of "tf get" and if it matches "All files are up to date" then do nothing, else trigger the SonarQube execution.

Can we run TestNG test cases via bat file on a independent machine? (machine which does not have the Eclipse project of the test being run)

I want to create a .bat file to run my TestNG test cases. I should be able to transfer the file to any computer and execute the test cases.
Is it possible to do the above in any way. If yes how?
Thanks
See 4 - Running TestNG on TestNG's documentation page. There you will find information on how to run TestNG from the command line (the same commands can be used in a batch file).
Note that batch files are specific to Windows. If you want to be able to run this on any platform that supports Java and TestNG then I recommend that instead of a batch file you run TestNG programmatically from Java.

Automate Build script from Batch to MSBUILD/NANT

I am trying to automate a build process for a C# (vs2008) solution.
The build script is written in a Batch script which I want to change. We use Clearcase as the CM system. I have searched some tools such as MSBUILD, NANT.
Any suggestions which is a better solution like a sample script in MSBUILD and NANT?
I have not seen any sites where MSBUILD and NANT is documented well or any good tutorial about each task description.
Where I can learn MSBUILD or NANT either of them and write script from scratch?
There is a third way which I prefer. You can also use devenv.com. It's faster than NANT, doesn't require NANT bins and works on any machine with VS installed. You also avoid possible errors with MSBUILD (http://support.microsoft.com/kb/964125).
Just use %path_to_devenv.com%\devenv.com "%path_to_sln" /<buildoption> BuildConfig
In my case it's
%ProgramFiles(x86)%\Microsoft Visual Studio 10.0\Common7\IDE\devenv.com "C:\Projects\XYZ\xyz.sln" /rebuild Debug
This way it's guaranteed that your project will be build exactly the same way as it's being built in Visual Studio.
EDIT:
Now that we know how how much there is to do, I'll try to give an outline how you can setup the whole system for automated build controll.
Set up your repository (I hope this is already done - tell me if not)
Install and set up Jenkins (https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins) including users, ClearCase-Credentials, plug-ins for ClearCase, MSBuild, etc. (all of them can be found in the Jenkins plug-in interface) - this is the biggest peace of work
Create and set up a new project in the jenkins interface (name, working directory, etc.)
Tell jenkins to use source code management (e.g. subversion module), enter the ClearCase repos to use, set the desired behavior of the source code management
Set a build trigger (I recommend checking the source code management each minute: * * * * *)
Add a build step and select "Build a Visual Studio project or solution using MSBuild" - this option should appear after installation of the MSBuild plugin (https://wiki.jenkins-ci.org/display/JENKINS/MSBuild+Plugin)
Set the path to the .sln file (you have checked it out from your repository)
Add more optional arguments if desired (eg /p:Configuration=Release or Debug or whatever http://msdn.microsoft.com/en-us/library/vstudio/ms164311%28v=vs.110%29.aspx)
Play around untill it works
Btw., I recommend to put all external dlls into your repository.

how to make installer (exe) file in windows

I have created a WPF application. I want to make installer file (exe) for this application.
This application also uses some other 3rd party files (bat files); which i have zipped.
I want to unzip this file while installing and set the path of unzipped dir in Path variable also.
I got a link http://www.msdotnet.co.in/2012/06/how-to-create-setup-fileexe-file-from.html#.U3GT7YGSzxp
which tells how to create a installer file.
How to achieve unzipped part and setting environment vairable while making installer?
Thanks
Take a look at wix from Microsoft.
It can be run standalone, but is great run from within visual studio. You write a small xml file detailing what you want installed, and it does the rest.
To run a zip command, use a CustomAction.
Search for Install-shield. It is old tool but having good scripting capability like what you are expecting (i.e) Unzipping the folder and dealing with path environment variable
Use Inno Setup (http://jrsoftware.org/isinfo.php) or NSIS (http://nsis.sourceforge.net/Main_Page).
Both are free (open source) installation systems with many possibilities and huge community around (even here on SO).
They are really easy to use (especially Inno) and they are powerful so it is easy to achieve your required functionality.
Take a look at Stall:
https://github.com/jamesqo/Stall
It's an OSS project that lets you install your app from the command line, no configuration required.
Example Usage:
stall path/to/YourApp -e YourApp.exe -i YourApp.exe
This installs your app straight to the user's computer without having to make an intermediary MSI.
If you have to unzip files as well, you may want to just consider a simple batch files that downloads the binaries + unzips the contents + runs Stall.

Make a Single EXE from BATCH and 2 EXEs

I have a script (a.bat) that calls 2 executables (b.exe and c.exe) and I would like to create a single exe that would call a.bat automatically.
Is it possible?
Any simple program to do this?
Ps.: Info: The Exe's do make other files that are deleted in the end
Not directly, no.
The simplest way to accomplish this with off-the-shelf tools is to use an archiver that can create self-extracting archives and allows to specify a file to run after extraction. For example, free Info-Zip tools support an autorun command. WinRAR (commercial) allows to define complex scripts with GUI.
An install engine can be used for the same purpose. For a couple of examples, there are NSIS and Inno Setup (both free).
A (relatively) more complex solution is to write a third executable that will extract payload from its resources and run the batch file. This way you have full control over what happens.
This One:Bat To Exe Converter
It has the "Include" option that can include the exe file
when the compiled exe file run
it will release it
and you can run it!

Resources