Questions tagged [automocking]

Use automocking for questions related to programmatic creation of mocks from source code and metadata.

References

70 questions
4
votes
1 answer

Jest: automock modules, but only those defined in __mocks__, rather than all

TL;DR I would like to have some kind of automock feature enabled, but only (and only!) for the modules that I have explicitly defined in a corresponding __mocks__ folder. Is there a way for this in Jest? General advices and suggestions are also…
jayarjo
  • 16,124
  • 24
  • 94
  • 138
4
votes
1 answer

In TestCafe Is possibile to register xhr and use as mocking (automocking)

I'm using testCafe for my functional test. My project used a lot of XHR request and I don't want to waste my time to generate each single mock. Exists an automocker like this: https://github.com/scottschafer/cypressautomocker for testcafe?
user2354037
  • 195
  • 2
  • 8
4
votes
0 answers

Qt5 and CMake: add headers for AUTOMOC

Qt with CMake often leads to trouble during linking. After reading several posts and tries I found out that AUTOMOC takes source files given with add_executable but ignores my header files inside the include folder given with include_directories(…
Alex44
  • 3,597
  • 7
  • 39
  • 56
4
votes
1 answer

Handle files with the same name by automoc

There is the following source tree: *-source *----subsource *--------Source1.hpp *----Source1.hpp Both files, ./Source1.hpp and ./subsource/Source1.hpp, must be handled by moc. When using automoc it puts output moc files to the same directory with…
Yuki
  • 3,857
  • 5
  • 25
  • 43
3
votes
1 answer

Cannot mock fs with jest using typescript - Property 'mockReturnValue' does not exist on type

Problem: Would someone help me figure out how to mock fs with jest using typescript? I've tried a few things, and here is the main one: I'm attempting to use jest to mock 'fs', but I can't seem to get jest to automock the 'fs' library in…
Greg Micek
  • 183
  • 3
  • 16
3
votes
1 answer

Moq requirements? Defeats the purpose?

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…
bevacqua
  • 47,502
  • 56
  • 171
  • 285
3
votes
1 answer

MoqAutoMocker and primitive constructor parameters

I am an avid user of the StructureMap MoqAutoMocker, sometimes, however, we run into an "old friend" of ours. Assume a class "Validator" public class Validator { private string _connectionString; private IEventMachine _eventMachine; public…
Pedro G. Dias
  • 3,162
  • 1
  • 18
  • 30
3
votes
2 answers

Create class and auto-initialize dependencies with FakeItEasy

Is it possible to create a class under test with FakeItEasy, where all dependencies that are declared in the constructor are initialized automatically with fakes? Imagine the class: public class Inserting { public Inserting( …
Alexander Pacha
  • 9,187
  • 3
  • 68
  • 108
3
votes
1 answer

Ninject: auto mocking using NSubstitute?

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…
Martin
  • 23,844
  • 55
  • 201
  • 327
3
votes
1 answer

Automocking the SUT

I have read Mark Seeman's article on auto-mocking and I'm now writing a re-usable windsor container based on that article. My implementation of Mark's article (basically copied directly) The main work is done in the AutoMoqResolver class. This will…
Nick Soper
  • 765
  • 1
  • 5
  • 12
3
votes
1 answer

Using cmake's automoc on external header files without knowing their filenames

In essence I want to be able to moc header files that are not part of any target in cmake with the additional difficulty that I don't know the filenames of those headers. The actual project is quite complex and part of an automated build system. The…
ifschleife
  • 1,055
  • 1
  • 10
  • 21
3
votes
0 answers

AutoMockContainer - Error when calling controller

Been playing around with AutoMocking. While using moq.contrib.indy am getting the following error when calling the controller {"Value cannot be null.\r\nParameter name: controllerContext"} var mocks = new AutoMockContainer(new…
Dr.
  • 167
  • 3
  • 11
2
votes
1 answer

Mocking Func property of a class

one of my repository class (say PersonRepo) has a delegate as its property something like this private readonly Func _nameRepo; and apart from this it is inherited by a class which itself expects one more object (say the session). Thus…
Baz1nga
  • 15,485
  • 3
  • 35
  • 61
2
votes
2 answers

Automoq Documentation

I am getting started with Automoq. I was trying to do something like this: mocker.GetMock(); var line = mocker.Resolve(); line.PropertyOne = .75; line.PropertyTwo = 100; MyCalc calc = new…
JChris
  • 41
  • 3
2
votes
1 answer

How Structure Map Automocker Inject works?

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…
Petr Behenský
  • 620
  • 1
  • 6
  • 17