Deploy MSTest projects - c#

I was wondering if it would be possible to either write or deploy an existing test runner along side my MVC application. The tests could be referenced from the test Runner application and deployed separately from the main application.
The aim is to run the tests remotely on client site as a sort of diagnostics tool.
It would be great if we could have a little more information when things go wrong.
Is this possible?

Related

How to integrate Custom automation framework with MTM

We have a custom automation framework in place. So for running scripts we have a windows application for trigger some test case. Test cases are simple C# methods and we invoke them using Reflection.
Now My requirement is to integrate this framework with MTM. and would like to have continuous integration in process. This means I want if some build comes then some of the test case will automatically start running to secure our code.
How can I achieve this?
More specifically my requirement is I pushed some code related to some PBI, So the testcase related to that requirement should automatically run.
Generally the CI (continuous integration) is against the build process in TFS.
If you mean run the tests using custom test framework, then you need to create a Test Adapter accordingly, so that VS and the Build server can pick up the tests. Here is a good article for your reference on how to do this: Authoring a new Visual studio unit test adapter
Actually you can run the tests in build process, with the CI set, the new build will be triggered once a new change checked in, then the tests will run automatically. Refer to below articles for details:
vNext build - Testing in Continuous Integration and Continuous
Deployment Workflows
Xaml build - TFS, Automated Testing and Continuous Integration
If you still want to use MTM, you can reference below articles:
Automate a test case in Microsoft Test Manager
Continuous Delivery with TFS: Running Automated Web Tests with
MTM

can I do unit testing of an ASP.net MVC project from a console program?

I'm getting started on unit testing in an ASP.NET MVC project. What I've seen of unit testing methodology suggests that people create different controllers to run the unit tests, which suggests that the unit testing occurs within the MVC environment. Is there a way to set up enough of an environment so that you can link to the MVC dll as a project from a console application and call controller tests from the console program? That would avoid having to have a local IIS running to do test, etc.
thanks!
john
While you can run units tests from a console app (or MVC app for that matter), you shouldn't.
As Fran mentioned, you should be running them from within your Test Framework Application or Visual Studio itself... There are plenty references for this;
https://msdn.microsoft.com/en-us/library/ms182470.aspx?f=255&MSPPError=-2147217396
https://learn.microsoft.com/en-us/visualstudio/test/run-unit-tests-with-test-explorer

How to automatically start ASP.NET MVC web app before executing Selenium Web-driver tests?

I would like to test ASP.NET MVC webpage by MSTest using selenium driver. I suppose I need to start the ISS and start web application somehow, get the url of the web app (localhost at some port) and then start test.
There are many examples how to use selenium driver but they all work with already configured urls.
My expectation is following:
Anyone who just clone the git repository with this web app and open solution in Visual studio, click run all test. The web app is started and test are executed.
It should also work as part of continual integration (for example with Teamcity) where these unittest are executed using MSTest on different computers.
It would be nice if this solution works also on computers without Visual Studio Installed (just nuget, MSBuild, MSTest and various SDKs).
There are a few things you should be able to do here.
1) If you have Visual Studio, you can write a powershell script that will spin up the local site you need to run the tests against. This may help you.
You'll then need to also create a script that will run your selenium scripts after the site starts. I've only done this with Microsoft WebTests, but I've seen the similarities with Selenium. I'd look into running your selenium scripts from a powershell script, then combine these two, and have a batch file which new users can just click and to run the tests.
2) You can certainly run these scripts from TeamCity, there just may be some additional configuration like installing necessary tools on the build server. TeamCity has build in tools to run these tests though, so look to utilize that.

Web-based unit-testing in C#

I have a bunch of C# unit tests on my teams Team Foundation Server. Normally we Run these tests using Jetbrains test-suite. However, I've like to make these tests available to the QA department, through a browser.
Is there any way to easily make C# unit test runnable through the web? Anybody who have experience with this?
I have googled it and i'm only able to find client applications to run unittests.
Thanks in advance!
Your Unit Test should be for developers and Continuos Integration process, QA departement should run UI/Web Coded/Performance Test by VS Test Manager; anyway if you configure the execution of the test suite in the build configuration, test result will be available also from TFS Web Access
Run tests in your build process

Automated TFS-based CI UI tests with desktop interaction

I'm running some automated Continuous Integration tests through a TFS build. The tests are written using the Microsoft UI Automation Framework on MSTest, and are configured to run locally on the build agent, without any controller or agent.
Now, the tests themselves execute well. The Startup method of the test suite launches the compiled application's executable and the process shows up in the server's task manager. However, since this is done through the Team Foundation Build Service, the UI isn't actually shown, as services are not allowed to interact with the active desktop.
Is there a way to force the application's UI to appear on the active desktop? I'm aware that I can install a test controller and agent that allow tests interaction with the desktop, however this creates additional overhead and some technical problems, as we're using VS2012 against TFS2010, which goes directly to the VS2010 MSTest and thus to the VS2010 test controller & agent, which I cannot configure through VS2012.
I ended up setting up a test controller a test agent. Apparently, with VS2010 it's not possible to install a test agent on the same server with the build controller, so I went for a separate machine altogether.
The tests run nicely now!
With what account are you logged on to the build server?
Only if you are logged on with the build account you will see the interaction with the desktop/UI.

Categories

Resources