How to include chutzpah test cases in tests project to output folder - angularjs

I have a web project, say 'WebProj' in which I have defined all the my javascript source files with angular code. I am defining my chutzpah unit test cases for those javascript source files in another project 'WebProj.Tests' along with my other C# test cases. I am having both the web and tests project under same solution.
My problem is that when I try to integrate the web project to the TFS build process I cannot run the chutzpah test cases as the web project output folder don't have the chutzpah test case files copied to the project output folder. At the same time the test cases are executed if I have the chutzpah test cases defined in the same web project.
How can I execute the javascript chutzpah test cases on build process if those are defined in a separate Test project and include them in project output folder after build?

To have the test case files copied to the build output folder, you need to right-click the .js file and select Properties -> set the Copy to Output Directory property to be Copy always.
Additionally, you need to follow the steps below to run chutzpah tests in TFS build process.
Install jasmine.js to the test project.
Install Chutzpah Test Adapter
Install Chutzpah test runner to the solution (on solution level, not project level).
Set the test assembly to match your javascript test naming convention. e.g. ***.tests.js
Configure to use the custom test adapter during TFS build process. 1). If you are working with vNext build, go to Visual Studio Test step, set the Path to Custom Test Adapters property to be similar to $(Build.SourcesDirectory)\packages (get the path via NuGet restore); 2). If you are working with XAML build, go to Build –> Manage Build Controllers, set Version Control Path to custom Assemblies to the package path.
Completed steps can be found on the "But what if you want run Jasmine.JS test?" part in this blog: http://blogs.blackmarble.co.uk/blogs/rfennell/post/2015/09/23/Running-nUnit-and-JasmineJS-unit-tests-in-TFSVSO-vNext-build.aspx
And also this blog (do not follow the Step2 to check in these files into TFS version control, instead use NuGet to donwload these packages.) http://blogs.msdn.com/b/visualstudioalm/archive/2012/07/09/javascript-unit-tests-on-team-foundation-service-with-chutzpah.aspx

Add another Visual Studio Test step to your build definition that just runs the JavaScript tests as shown below; the redacted portion in the green box of the Test step is the path to your test files. When the build runs, the stats from the two test runs will be combined in the build output.

Related

How to include Publish profile and application parameters in a package of service fabric application for deployment?

I am trying to package Service fabric application, when i do that i have application manifest and service manifest files but i want to include application parameters and Publish profiles as well.
Not sure what CI system you're using but typically there's three parts to make it all work
Package your application output + manifests. This is basically the package location output you get from doing an MSBuild on your sfproj. In below, I'm assuming CI build artifact output go to '$(build.artifactstagingdirectory)'
/t:Package /p:PackageLocation=$(build.artifactstagingdirectory)\applicationpackage
Include a step in your CI build output to copy the the parameter and profile files to another folder - e.g. $(build.artifactstagingdirectory)\projectartifacts
**\PublishProfiles\*.xml
**\ApplicationParameters\*.xml
Deploy your application. For this, have a look at the Deploy-FabricApplication.ps1 script that's created by Visual Studio when your first created your .sfproj Service Fabric project. This is also used by Visual Studio when you deploy your application to your local development cluster and you essentially have to perform the same steps to deploy to another cluster.
A simple example assuming your CI artifact output exists in "$(SF_PackagePath)"
Deploy-FabricApplication.ps1 -ApplicationPackagePath "$(SF_PackagePath)\applicationpackage" -PublishProfileFile "$(SF_PackagePath)\projectartifacts\Local.1Node.xml"

Jest unit tests in Visual Studio 2019 Test Explorer

I created a new ASP.NET Core React app using dotnet new react. Then I added some Jest unit tests, which run nicely when I run npm test on the command line.
I would like to be able to run the tests from Visual Studio 2019, either using the Test Explorer window or ReSharper.
First of all, it seems that ReSharper only supports Jasmine and not Jest (ReSharper documentation, Feature request).
So I tried using the Test Explorer, following this official guide. It has support for Jest. However, the React template for ASP.NET Core is not a node.js project, so the options for test framework and whatnot are not available. Thus, Test Explorer finds no tests.
Then I tried running the tests using the command vstest.console.exe MyProject.csproj /TestAdapterPath:"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\Extensions\Microsoft\NodeJsTools\TestAdapter". The output gives me some hope:
Microsoft (R) Test Execution Command Line Tool Version 16.5.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
No test is available in MyProject.csproj. Make sure that test
discoverer & executors are registered and platform & framework version settings are appropriate and
try again.
The test runner finds at least one test file (actually I have 2), but it doesn't know that it's supposed to use Jest executor. Can I maybe add something into the .csproj file to make it work?
This is how I got .njsproj to work. I hope to make a .csproj work as well. Start by creating a new Blank Node.js Console Application with TypeScript. Tested with JavaScript as well and it works.
Create a folder called tests and add a JavaScript Jest UnitTest file:
Failed to find "jest" package. "jest" must be installed in the project
locally. Install "jest" locally using the npm manager via solution
explorer or with ".npm install jest --save-dev" via the Node.js
interactive window. Failed to find "jest-editor-support" package.
"jest-editor-support" must be installed in the project locally.
Install "jest-editor-support" locally using the npm manager via
solution explorer or with ".npm install jest-editor-support
--save-dev" via the Node.js interactive window.
Then ran the following command from Developer Command Prompt for VS 2019:
vstest.console.exe "C:\Users\Oscar\source\repos\NodejsConsoleApp1\NodejsConsoleApp1\NodejsConsoleApp1.njsproj" "/TestAdapterPath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\Microsoft\NodeJsTools\TestAdapter"
Installed jest and jest-editor-support with Dependency type Development.
After doing this the tests can be ran:
The tests will now show up in Test Explorer as well:
Then rename UnitTest1.js to UnitTest1.ts. You should see the following error:
Install #types/jest as dev dependency and it should work:
I did not have to specify this but if something fails then check project properties and set JavaScript Unit Test values.
Also check the properties of the test file, if added via GUI these values should be correct by default.

How do I make my Setup project produce an executable?

I've built a small desktop application with which I am trying to use a Setup project to allow other users to install it. But whenever I run this installer, it does not produce an executable file. This is my first time making a setup project.
My solution contains two projects. One is the setup project which installs the primary output from the other project. The other project is a WPF App that consists of two xaml files, a xaml.cs file for each, an App.config file, and an icon. It also has a few dependencies including one Assembly, two Frameworks, and a handful of Packages. The app works exactly as intended whenever I start a Visual Studio debugging instance on either Debug or Release configurations.
I followed these instructions to build my Setup and deploy my app.
Whenever I ran the resulting Setup, it installed an XML configuration file, a JSON file, a main application dll file, and a bunch of dll files for my assemblies. I looked into some resources on how to run the main dll file properly, only (A) I'm completely stumped by everything I find on that topic, and (B) I would rather just produce an executable file anyway, since I intend for this Setup project to be used by other people and it would be inconvenient to ask said others to jump through the same hoops just to run it.
Why does my Setup project not produce a .exe file? I see that a .exe file is produced in my bin folder whenever I build my project (and this .exe works), so I would think the setup project should also produce one of those, but it doesn't. What am I doing wrong with my Setup project or anything else?
The setup.exe is a bootstrapper over the setup.msi. We can install the content using .msi or by running .exe which inturn runs /gets the data from the msi. To enable setup.exe building, go to solution explorer -> project -> properties -> prerequisites. check the check box on the top "Create setup program to install prerequisite components". apply and rebuld the project. A setup.exe bootstrapper will be created allong with msi.
Switch to Release mode, then rebuild your setup project. If everything went well (check the output console), you'll find an MSI file inside {setup project folder}/bin/Release
In "system file" from your proyect installer, you shoud to add in "Application Folder" the next source = PublishItemsOutpuGroup. In my case functions well.

Packaging Smoke tests as an (additional) executable jar in Gradle build

We have a gradle build creating a SpringBoot web application. The SpringBoot app is tested with a variety of tests including a suite of WebDriver 'journey' tests. We run a subset of these journey tests as 'smoke' tests on different environments.
To make this as simple as possible we want to create an executable FatJar (or similar) consisting of a Main class, the smoke tests and testing dependencies. This artifact should be created in addition to the main application jar and can then be run against an arbitrary environment from the command line.
What's the best way of achieving this? Sub-projects don't seem to fit because we want to package the 'test' output from a single project. The spring-boot gradle plugin seems to be (rightly) geared to producing a single application artifact, is there a way to MacGyver it to create another executable jar with the smoke tests? Is this just crazy talk?

How can one import the whole webDriver project in an executable form so that anybody else can run the suite by just a click.?

I am relatively new to Selenium WebDriver and a self learner. I have created a webDriver project which consists of different packages and have made use of Page Factory concepts extensively. I use TestNg framework to run the suite to generate my report. So my test cases are also following the TestNG framework concepts.
Now my team wants to use my script to be run at every build to test the sanity. The build team just wants to run my whole script by just a click. It can be shell script command or .exe or jar. Build team uses linux m/c and they dont have Ecplise , TestNg installed in their machine. Their intention is whenever build is given they want to run my script by just a click or a command in Command Prompt.( it has to be that simple for them) and a report should be generated in some location in hdfs
My script runs on FF version 32 and Selenium webDriver 2.44.0
Would really appreciate if someone could give me a solution that actually works for my requirement.
I found a similar query from someone but i am not sure if the answer still suits.
How to make Java executable Jar file of WebDriver project
Could somebody please give me a solution. Or the solution mentioned in the above link stil is the best?
Regards
There are few ways to do it:
Use CI tool (Jenkins): You can set up your project in Jenkins and it will allow you to run the project in single click. Jenkins also provides you an option to run the tests periodically so you can configure it in such a way that it will always get executed after certain time period.Jenkins is also capable to trigger the execution if there is any changes in source code of tests. I'd suggest to use this tool. https://jenkins-ci.org/
Use .bat or .sh file: I am not sure if you are using any build tool like ANT or Maven, if you are using any one of them then you can write a .bat or .sh file to run the tests. ANT
If you are not using any build tool then start using, it will help to run the tests in simplest way.For me to run entire suite, I just type below command in terminal from root directory of project
ant run -Dsuite=all
If you are more concerned about system configuration for e.g. the system which will be used by build team does not have a specific version of browser or specific required library. Then I'd suggest to keep all essentials like browser installation files, libraries in your project directory. This is not a good practice but yes it will help others to run the tests smoothly.
I would suggest just exporting a jar file for your project. All the libraries will be packaged together in the jar files(including TestNG) and you can simply double click on the jar file to start your tests.
External resources (if any), will have to be available for the jar file though. So, you can provide the jar file and the external resources together. The external resources might include your test data (if any) or Portable Firefox(if you are using the portable version).
Steps:
Right click on Project -> Export -> Runnable jar file
Give a name and file path for the jar file
Select option - Extract required libraries into generated JAR
And Finish
Troubleshooting:
Check the java version for the machines that you will be running your jar file on. Programs compiled with java 7 will mostly not run if the machine has java 6. Either compile with java 6 or update the jre on the target machines.
If the jar file does not launch, try using Jarfix.

Resources