automocking

CMake and Qt5 AUTOMOC error

折月煮酒 提交于 2021-02-18 15:51:41
问题 I have a project which uses Qt5 and I have a CMakeLists.txt file that I use for creating the Visual Studio Solution. This is an excerpt of my CMakeLists.txt cmake_policy(SET CMP0020 NEW) set(CMAKE_AUTOMOC ON) find_package(Qt5 REQUIRED COMPONENTS core widgets) set(COMMON_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/src) include_directories( ${Boost_INCLUDE_DIRS} ${COMMON_INCLUDE_DIR} ) file(GLOB_RECURSE COMMON_SOURCE "*.hpp" "*.cpp") add_library(${PROJECT_NAME} ${COMMON_SOURCE}) qt5_use_modules(${PROJECT

When setting up a custom AutoDataAttribute for auto mocking, what's the proper syntax to tell AutoFixture to ignore all recursive structures?

吃可爱长大的小学妹 提交于 2021-01-29 03:09:46
问题 I have xUnit/Moq/AutoFixture successfully working together so that I am auto mocking objects via test method input parameters. I created a custom [AutoMoqData] attribute which I use on every test. Here's the code for the attribute: using System.Linq; using AutoFixture; using AutoFixture.AutoMoq; using AutoFixture.Xunit2; namespace Shared.TestResources.AutoFixture { public class AutoMoqDataAttribute : AutoDataAttribute { public AutoMoqDataAttribute() : base(() => new Fixture().Customize(new

How Structure Map Automocker Inject works?

☆樱花仙子☆ 提交于 2020-01-04 12:47:41
问题 I have constructor containing IEnumerable parameter. When I try to Inject concrete object to automocker it is not used. When I use wrapper class containing IEnumerable property all works as expected. How can I test TestClass1? IEnumerable parameter public class TestClass1 { public TestClass1(IEnumerable<IItem> items) { Items = items; } public IEnumerable<IItem> Items { get; private set; } } [TestMethod] public void TestClass1Constructor() { RhinoAutoMocker<TestClass1> autoMocker = new

Moq requirements? Defeats the purpose?

隐身守侯 提交于 2020-01-02 07:32:45
问题 Doesn't being required to virtualize all property accessors you want to mock kind of defeat the purpose of mocking? I mean, if I have to modify my object and virtualize every single accesor I want to mock, couldn't I just as well inherit my class and mock it myself? 回答1: Your question is very valid but if you think about it,there is no other way to mock a class. If you take an interface, it's just a contract so the mock framework can mock how ever you want it but if you take a class, it

How to spy the class under test with AutofacContrib.NSubstitute

让人想犯罪 __ 提交于 2019-12-31 04:39:07
问题 I'm running unit tests in a class library project with NSpec framework, AutofacContrib.NSubstitute v3.3.2.0, NSubstitute v1.7.0.0 (the latest as of now is 1.8.2). The Class Under Test instance is built with AutoSubstitute , in order to automock all its needed dependencies. AutoSubstitute autoSubstitute = new AutoSubstitute(); MainPanelViewModel viewModel = autoSubstitute.Resolve<MainPanelViewModel>(); If working properly, my Class Under Test at some point will invoke one of it's base class

AutoFixture/AutoMoq ignores injected instance/frozen mock

别说谁变了你拦得住时间么 提交于 2019-12-21 03:53:18
问题 The short takeaway now that the solution has been found: AutoFixture returns frozen the mock just fine; my sut that was also generated by AutoFixture just had a public property with a local default that was important for the test and that AutoFixture set to a new value. There is much to learn beyond that from Mark's answer. Original question: I started trying out AutoFixture yesterday for my xUnit.net tests that have Moq all over them. I was hoping to replace some of the Moq stuff or make it

Ninject: auto mocking using NSubstitute?

梦想与她 提交于 2019-12-12 14:14:27
问题 Can anyone help, I am having problems using the auto-mocking that is available between Ninject and NSubstitute, actually the package is a ninject packaged called Ninject.MockingKernel.NSubstitute which should allow me to use Ninject to create mocks and return instances with mocks injected. There seems to be a few examples for Moq and Rhinomocks but I don't see any for NSubstitute. What I have so far is this.kernel = new NSubstituteMockingKernel(); var summaryService = this.kernel.GetMock

AutoFixture as an Automocking container vs Automocking differences?

人走茶凉 提交于 2019-12-12 07:12:18
问题 I started to use moq but from my understanding I always have to mock up all the methods that could be called even if I really do not care about them. Sometimes it takes so long to mockup stuff you forget what you want to do. So I been looking at auto mocking but I am not sure what one I should use. AutoFixture as an auto-mocking container Automocking I don't get how to use the first one at all. I sort of get the second one but never really tried it. I am not sure if one is better than the

Moq requirements? Defeats the purpose?

柔情痞子 提交于 2019-12-06 00:35:55
Doesn't being required to virtualize all property accessors you want to mock kind of defeat the purpose of mocking? I mean, if I have to modify my object and virtualize every single accesor I want to mock, couldn't I just as well inherit my class and mock it myself? Your question is very valid but if you think about it,there is no other way to mock a class. If you take an interface, it's just a contract so the mock framework can mock how ever you want it but if you take a class, it already has an implementation for it's members. So the mock framework, in order to be able to mock the class

What are the differences between MOQ and AutoFixture?

喜夏-厌秋 提交于 2019-12-05 16:43:12
问题 I have a fair amount of experience using MOQ, while I've recently have stumbled into AutoFixture. What are the differences between these frameworks? 回答1: The FAQ explains the difference. In short AutoFixture uses Reflection to create 'well-behaved' instances of public types. It auto-generates instances of other types if necessary to fill in arguments for a constructor, and also assigns values to public writable properties. In essence, it simply uses the requested type's public API to