mstest

MSTest with Moq - DAL setup

感情迁移 提交于 2019-12-10 23:46:04
问题 I'm new to Moq, and just started on a project that's already in development. I'm responsible for setting up unit testing. There's a custom class for the DatabaseFactory that uses EnterpriseLibrary and looks like this: public Database CreateCommonDatabase() { return CreateDatabaseInstance(string.Empty); } private static Database CreateDatabaseInstance(string foo) { var database = clientCode == string.Empty ? DatabaseFactory.CreateDatabase("COMMON") : new OracleDatabase(new ClientConnections()

All tests pass but TFS marks the build as partially succeded

大憨熊 提交于 2019-12-10 22:24:13
问题 Our current project involves building a robotized box controlled by a .Net application. We interface with quite a few hardware libraries and we did set up a integration server with all the hardware connected to it to run nightly regression tests. Unfortunately, not all hardware libraires in our setup integrates nicely with TFS and MSTest. When we run our build and tests with a certain librairy, we have either one of these 2 behaviors: All tests are martked as passed in TFS but the build is

Method for handling exceptions in mstest

我与影子孤独终老i 提交于 2019-12-10 21:43:09
问题 I have a lot of tests writen in this format: [TestMethod] public void TestMethod1() { try { DoShomething(); } catch (Exception e) { WriteExceptionLogWithScreenshot( e ); } } [TestMethod] public void TestMethod2() { try { DoAnotherShomething(); } catch ( Exception e ) { WriteExceptionLogWithScreenshot( e ); } } I would like to unify this exception handling using something like [TestCleanup] public void Cleanup() { // find out if an exception was thrown and run WriteExceptionLogWithScreenshot(

Querying failed unit tests from TFS-SDK?

混江龙づ霸主 提交于 2019-12-10 21:23:03
问题 Given a TFS build detail (IBuildDetail) with .Status of PartialSuccess , and .TestStatus of Failed how might I go about retrieving the list of tests (MSTest) that have failed on that build? I have a working sandbox in which I can contact TFS via the SDK and retrieve the latest PartialSuccess build, but can't seem to find which service might have this unit test data and how I might go about querying it. Can anyone shed some light? 回答1: This article is a great resource, actually it was the only

Gallio error : MSTest executable was not found

风流意气都作罢 提交于 2019-12-10 19:16:54
问题 I've got an annoying issue with Gallio when I try to analyse my VS2012 C# solution with my sonar-runner. When Gallio try to launch my unit test I can find this issue in the logs : [error] Assembly XXXX Cannot run tests because MSTest executable was not found I've already tried some propositions of solution exposed here and here (I have installed Agents for VS 2012 and I have added a registry key with the path of my VS2012 installation) but nothing seems to work. Thank you by advance for your

Forcing ClassInitialize to execute before testmethod data is read

ε祈祈猫儿з 提交于 2019-12-10 19:12:44
问题 I'm having a problem with the classinitilalize method of a unit test being executed after the evaluation of the attributes on a unit test. These tests use a [classinitialize] method to generate a test set that makes a random set of data in an xml file. The xml file is consumed by a unit test with the attribute [datasource]. A trimmed down version of this looks like this: [ClassInitialize] public static void Initialize(TestContext context) { // Create xml output file var output = new XDocument

When MSTest fails in TestInitialize, why doesn't TestCleanup get executed?

送分小仙女□ 提交于 2019-12-10 18:18:53
问题 I have a base class that has a TestInitialize and a TestCleanup in it. I then have other test classes which inherit from this class. The TestCleanup is supposed to perform certain actions when a test from the derived class fails. The TestCleanup gets executed when the test fails in the actual test. However, when the test fails in the TestInitialize , the TestCleanup doesn't even get executed. Why does this happen and is there a way to get the TestCleanup to get called anyway? I don't think

teamcity says Test xxx cannot be found for MSTests

你离开我真会死。 提交于 2019-12-10 18:12:16
问题 For the life of my I'm trying for weeks for Teamcity to run the MSTests I have in my a unit test project which is part of the solution I'm building but I've failed. Below I list the various combinations of settings I've tried and their outcomes. The best I've got is I can go as far as getting Teamcity to know something about my tests but it can't find them. I have tried several solutions but all of which have two outcomes. Here is the MSTests settings screen for reference: If I specify a

Why is referenced dll getting locked while debugging under Resharper/MSTest?

a 夏天 提交于 2019-12-10 17:49:25
问题 I have an integration test for a method in assembly A . Assembly A references assembly B via project reference. I run them under the Visual Studio 2010 debugger in a Resharper 6.1 unit testing scenario. The testing engine is Microsoft's native MSTest. I get the infamous The process cannot access the file ...\B.dll because it is being used by another process. message. I have verified that no other process has a handle on that file (e.g. via Sysinternal's Process Explorer). Running the test out

NLog not working with MSTest, where should the config go?

天涯浪子 提交于 2019-12-10 17:33:29
问题 We have recently migrated tests from NUnit to MSTest and I am struggling to get previously passing tests runnning. From what I can deduce MSTest cannot detect the NLog configuration. I have my Nlog configuration in my App.config which didn't cauise an issue with NUnit. Has anyone any ideas? 回答1: Change the Copy to Output Directory setting for your App.config to Copy Always or Copy if Newer . More on this here. 来源: https://stackoverflow.com/questions/4509987/nlog-not-working-with-mstest-where