tdd

How to exclude certain tests in the Visual Studio Test Runner?

限于喜欢 提交于 2019-11-27 02:08:43
问题 I have attributes on certain tests that I ideally don't want to run on every build. Most of my tests are normal unit tests and I do want them to run on every build. So: how can I exclude a test by category or project type? For example, I'd like to exclude CodedUItests : [CodedUITest] public class SearchViewTests ...or exclude tests in a given TestCategory : [TestMethod] [TestCategory("Database Integration")] public void ContactRepositoryGetByIdWithIdExpectCorrectContact() I particularly want

Mocking free function

女生的网名这么多〃 提交于 2019-11-27 01:46:35
I am stuck in a problem and can't seem to find the solution. I am using VS2005 SP1 for compiling the code. I have a global function: A* foo(); I have a mock class class MockA : public A { public: MOCK_METHOD0 (bar, bool()); ... }; In the sources, it is accessed like this: foo()->bar() . I cannot find a way to mock this behavior. And I cannot change the sources, so the solution in google mock cook book is out of question. Any help or pointers in the right direction will be highly appreciated. :) πάντα ῥεῖ No it's not possible, without changing the sources, or bringing your own version of foo()

Mocking Static methods using Rhino.Mocks

强颜欢笑 提交于 2019-11-27 01:39:44
Is it possible to mock a static method using Rhino.Mocks? If Rhino does not support this, is there a pattern or something which would let me accomplish the same? Is it possible to mock a static method using Rhino.Mocks No, it is not possible. TypeMock can do this because it utilizes the CLR profiler to intercept and redirect calls. RhinoMocks, NMock, and Moq cannot do this because these libraries are simpler; they don't use the CLR profiler APIs. They are simpler in that they use proxies to intercept virtual members and interface calls. The downside of this simplicity is that they cannot mock

How do I mock static methods in a class with easymock?

点点圈 提交于 2019-11-27 01:33:21
Suppose I have a class like so: public class StaticDude{ public static Object getGroove() { // ... some complex logic which returns an object }; } How do I mock the static method call using easy mock? StaticDude.getGroove() . I am using easy mock 3.0 Ben J Not sure how to with pure EasyMock, but consider using the PowerMock extensions to EasyMock. It has a lot of cool functions for doing just what you need - https://github.com/jayway/powermock/wiki/MockStatic Easymock is a testing framework for "for interfaces (and objects through the class extension)" so you can mock a class without an

Jest: how to mock console when it is used by a third-party-library?

蹲街弑〆低调 提交于 2019-11-27 01:26:51
问题 I am trying to mock console.warn/error but i can't. I use a third-party-library which calls console.warn inside it. I need to test was it called or wasn't. In my test case i was trying to stub console.warn but it didn't help. After that i was trying to mock console manually it didn't work out either. console.warn = jest.fn(); testSchema('/app/components/Users/UserItem/UserItemContainer.js'); expect(console.warn).toBeCalled(); didn't work console.warn = jest.fn(); testSchema('/app/components

Looking for papers/studies on TDD effectivness [closed]

一个人想着一个人 提交于 2019-11-27 01:05:59
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I'm looking for research papers or studies made on Unit Testing and TDD effectiveness. Points of interest: Does TDD reduce Development time? Does overall development cost reduced as well? Is the result product more stable? 回答1: Microsoft Research: Realizing quality improvement through test driven development:

What do you test with your unit tests?

◇◆丶佛笑我妖孽 提交于 2019-11-27 00:18:35
问题 TDD is something that seems to be on everybody's lips these days, and I have tried some on my own but I don't think I'm getting the idea. I am getting a grip on how to write a unit test, but I don't understand exactly what my unit tests should test. If I have an action method that returns a list of data, what should I verify? Only that the view name is correct, or should I verify the data as well? If I should test the data as well, won't I be writing the same code twice? What is the use of

How do you mock the session object collection using Moq

[亡魂溺海] 提交于 2019-11-27 00:02:55
I am using shanselmann's MvcMockHelper class to mock up some HttpContext stuff using Moq but the issue I am having is being able to assign something to my mocked session object in my MVC controller and then being able to read that same value in my unit test for verification purposes. My question is how do you assign a storage collection to the mocked session object to allow code such as session["UserName"] = "foo" to retain the "foo" value and have it be available in the unit test. I started with Scott Hanselman's MVCMockHelper , added a small class and made the modifications shown below to

Why should I practice Test Driven Development and how should I start?

拥有回忆 提交于 2019-11-26 23:59:16
Lots of people talk about writing tests for their code before they start writing their code. This practice is generally known as Test Driven Development or TDD for short. What benefits do I gain from writing software this way? How do I get started with this practice? Mike Stone There are a lot of benefits: You get immediate feedback on if your code is working, so you can find bugs faster By seeing the test go from red to green, you know that you have both a working regression test, and working code You gain confidence to refactor existing code, which means you can clean up code without

Best Practices of Test Driven Development Using C# and RhinoMocks [closed]

假如想象 提交于 2019-11-26 23:45:14
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . In order to help my team write testable code, I came up with this simple list of best practices for making our C# code base more