Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to schedule C# unit tests with Jenkins?

Over the last 6 months our test team have been using selenium webdriver to test our web based products. We have had great success with it and continue to use it on a daily basis. We use visual studio since we are a .net shop to write our c# unit tests. We don't use any other testing frameworks for .net. We have up until recently been running our automation tests manually through the test explorer window in visual studio (2013), checking on the results and then logging them into a spread sheet. I know this isn't ideal but we don't have that many tests so this has suited us fine thus far. However, the number of automation tests we will be required to write and maintain is due to rapidly increase over the next few months.

I have recently been playing around with creating batch files for calling vstest.console.exe and its various commands and then adding those logs to a server. Not ideal. I know I can still do so much more, specifically integrate some sort of CI server.

We are already using team foundation server and have various virtual servers (all running windows 8.1) at our disposal so I thought about taking advantage of this so I began looking into Jenkins. Trouble is, I'm not finding much information regarding Jenkinks and c#. It looks primarily geared to a java setup. Am I missing something? What little information I have found is seriously outdated and didn't work for me.

I got as far as setting it up and installing the vstest.console.exe plugin but couldn't get a simple test to run. A current step by step guide that doesn’t pre-date 2012 would be great :) Do you guys think Jenkins is the way to go for c# and the .net framework? Is there a "standard" used within the c# community? I have heard of cruise control and I’m going to check that out. Is it a viable alternative? Easier to use with .net?

Here is essentially what we need:

  1. Continue writing our tests inside visual studio and creating c# unit tests
  2. Schedule a run of our unit tests on a remote / local server
  3. Write out a result / log file - nice reporting features on fails / passes would be great
  4. Email said file to qa / dev teams

I'm hoping some of you guys have been down this road once and can share some insights

like image 405
Banjaxx Avatar asked Dec 09 '14 17:12

Banjaxx


People also ask

What should I write in Schedule C?

Use Schedule C (Form 1040) to report income or loss from a business you operated or a profession you practiced as a sole proprietor. An activity qualifies as a business if: Your primary purpose for engaging in the activity is for income or profit. You are involved in the activity with continuity and regularity.

Can I file a Schedule C by itself?

You will need to file Schedule C annually as an attachment to your Form 1040. The quickest, safest, and most accurate way to file is by using IRS e-file either online or through a tax professional that is an authorized IRS e-file provider. Here are a few tips for Schedule C filers.

What can I deduct on Schedule C?

Schedule C is also where business owners report their tax-deductible business expenses, such as advertising, certain car and truck expenses, commissions and fees, supplies, utilities, home office expenses, and many more. A business expense must be ordinary and necessary to be listed as a tax deduction on Schedule C.

Where do I enter Schedule C income?

If you received a Form W-2 and the "Statutory employee" box in box 13 of that form was checked, report your income and expenses related to that income on Schedule C. Enter your statutory employee income from box 1 of Form W-2 on line 1 of Sched- ule C and check the box on that line.


1 Answers

It is possible to use Jenkins to run tests via batch scripts, reporting back to Jenkins via the NUnit or MSTest plugins. To do this, simply call the test runner from a Jenkins-executed script (see links below). The primary reason for doing this in my shop is that Jenkins is used to automate the build process, and automated tests are run every time new code is promoted. If you don't use Jenkins for build automation and reporting - i.e. you just want scheduling - the most basic solution would be Task Scheduler (as John O indicated). Plus, if you are using MSTest rather than NUnit then, as others have suggested, it is better to have a look at TFS.

If you really want to use Jenkins with MSTest, the following links may be useful from a configuration perspective:

Error trying to run mstest on jenkins - 2012

Example of running MSTest from Jenkins from above link:

"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\MSTest.exe" /testcontainer:Example.Tests\bin\Debug\Example.Tests.dll /resultsfile:TestResults.trx

Jenkins MSTestRunner plugin is unable to launch mstest.exe - 2014

If you can/want to use NUnit, check out the following:

How do you run NUnit tests from Jenkins?

Execute NUnit with Jenkins

Actually, for reporting purposes, logging to Excel or something similar isn't a horrible idea (particularly if your organization uses Sharepoint). Worst comes to the worst and you can't get anything to work, then one solution would be automating this reporting process by using Excel's COM Object Model to directly write results to the spreadsheet.

Would still suggest that TFS is your best bet, however.

like image 130
Orphid Avatar answered Oct 19 '22 19:10

Orphid