Questions tagged [automocking]

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

References

70 questions
1
vote
1 answer

NestJS with Automock gets undefined in dependency mock

Does someone know why I get undefined in the console for the dependency mock? example.service.spec.ts import { TestBed } from "@automock/jest"; import { ExampleService } from "./example.service"; import { ExampleEntity } from…
Nícolas Amarante
  • 165
  • 1
  • 1
  • 7
1
vote
1 answer

Recording external api using mockoon

I have just started using Mockoon tool and I am finding a way to record an api which is already created and running in a port like for example I have a api like http://10.12.150.25:8080/welcome which is already creating and I want to capture request…
Vasantha
  • 47
  • 5
1
vote
1 answer

AutoMock CreateInstance Type to mock must be an interface, a delegate, or a non-sealed, non-static class

I get the generic message below when mocking "autoMocker.CreateInstance();" with Moq.AutoMock.Automocker. The HeliumController class's constructor take several interfaces. How can I find which specific interface or constructor is…
M. Brandel
  • 45
  • 1
  • 7
1
vote
1 answer

IConfiguration keeps getting null value when mocking

May I enquire if I am mocking my IConfiguration correctly as I keep get a null error. I am trying to mock my controller where it reads the appsettings.json. ControllerOne.cs private readonly IConfiguration _configuration; public…
rosepalette
  • 186
  • 2
  • 19
1
vote
0 answers

C Mocking: How to do it correctly

I recently got into Unit-Testing embedded C Code. I'd like to test each module fully isolated from all the others. This approach requires me to simulate (or "fake") all the dependencies and external calls a module makes. Doing just that, I would…
Danish
  • 407
  • 3
  • 10
1
vote
0 answers

I am trying to generate a csv file using mockaroo curl request but I am not getting whole 1000 records in the response. What could be the reason?

I am trying curl command as curl "https://api.mockaroo.com/api/2066ab40?count=1000&key=8bf92810" > sample.csv. I want to get 1000 records in the sample.csv file, but I am getting only 4 records in the response as below. StatusCode :…
1
vote
2 answers

Moq CreateInstance fails when constructor has dependencies using Func

public class MyService { private readonly ISomething _something; private readonly Func _rarelyGetUsed; public MyService(ISomething something, Func rarelyGetUsed) { _something = something; …
acarter
  • 55
  • 10
1
vote
1 answer

Use mock.Provide() to Setup a delegate factory, used in the SUT constructor

I am trying to test the behavior of a class, when it's passed one stub object via a delegate factory. I made a version of the test in which all the class's dependencies (except the factory) are passed as Mock objects and it works as supposed to. Now…
M.Tach
  • 143
  • 1
  • 1
  • 8
1
vote
1 answer

Why is this Autofac mock's lifetime disposed in a simple MSpec test?

I've got a base class I'm using with MSpec which provides convenience methods around AutoMock: public abstract class SubjectBuilderContext { static AutoMock _container; protected static ISubjectBuilderConfigurationContext
Derek Greer
  • 15,454
  • 5
  • 45
  • 52
1
vote
2 answers

How to spy the class under test with AutofacContrib.NSubstitute

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…
superjos
  • 12,189
  • 6
  • 89
  • 134
1
vote
1 answer

Autofac Automocking in ASP.NET MVC

So I'm trying to use Autofac Automocking in ASP.NET MVC 5, but for some reason I can't get it to work. Here's the test so far: using (var mock = AutoMock.GetLoose()) { const string mainUserID = "MainUserID"; const string…
Fabis
  • 1,932
  • 2
  • 20
  • 37
1
vote
1 answer

AutoMocking classes with non-interface dependencies... Does a framework support this?

I am trying to mock a class that has a dependency on a concrete class, just like: AutoMockContainer with support for automocking classes with non-interface dependencies I tried 3 different AutoMocking Frameworks (UnityAutoMoq, AutoMoq and…
CurlyFire
  • 712
  • 2
  • 6
  • 18
1
vote
0 answers

How to use Automoqer with autofac

I'm trying to resolve a concrete class having a container with autofac My setup is something like this [TestInitialize] public void Setup() { _automoqer = new AutoMoqer(); _distributeProcessSink =…
Giorgio
  • 148
  • 4
  • 12
1
vote
1 answer

Limit Ninject.MockingKernel to mocking classes in my own namespaces only

I've just switched to using the NInject.MockingKernel extension for my tests (NSubstitute). However, it makes very hard to run my Web API integration tests because it will return mocks for all Web API interfaces also. Can I automatically limit its…
georgiosd
  • 3,038
  • 3
  • 39
  • 51
1
vote
1 answer

Automocking for Python?

I'm used to using AutoFixture.AutoMoq with C# and wanted to know if something similar is available for Python. I'm not using django or databases, so django-autofixture is not going to help me. What I'm looking for is something that cuts down on the…
Matt
  • 14,353
  • 5
  • 53
  • 65