Questions tagged [unit-testing]

Unit testing is a method by which individual units of source code are tested to determine if they are fit for use.

0
votes
0answers
7 views

How to fix error ' ld: symbol(s) not found for architecture x86_64 ' in gtest [duplicate]

I am trying out https://github.com/eranpeer/FakeIt with gtest to write sample unit test cases. I am executing the code on my Mac with clang, which throws the following linker error. bash-3.2$ make g++...
0
votes
0answers
12 views

Detect race condition in table driven test

I have a table-driven test and init var(worker) outside table loop. I run the test with go test -raсe and added t.Parallel() and no race condition was detected. Can I assume that my test free of race ...
0
votes
0answers
10 views

Calling managed C++/CLI from native C++

Is it possible for a native C++ dll to call C++/CLI code? I want to access C# code in C++ unit test. For this I created one C++/CLI wrapper(CLR dll). I am successfully able to instantiate C# class in ...
0
votes
1answer
8 views

Python mock vs unittest.mock patch

What is the difference between these imports? from mock import patch vs from unittest.mock import patch Are they the same?
0
votes
0answers
9 views

How to make a set up for unit testing with the bot framework (Echobot, using ITurnContext)

I'm trying to make unit tests for an Echobot (just to understand how it works so I can use it for my actual bot), but there is one problem I'm unable to fix. The problem that I'm facing is that I'm ...
0
votes
0answers
17 views

How to stub/mock a method's/constructor's parameter in jest for unit testing in nodejs?

I am quite new to node js and to jsest. I have a class to unit test using jest: import { Observable, from } from 'rxjs'; import { inject, injectable } from 'inversify'; import "reflect-metadata"; ...
1
vote
1answer
34 views

AngularJS unit testing Karma - unknown provider

I am trying to set up unit tests on our legacy AngularJS app. I am using the standard karma along with angular-mock to set up the tests cases. But I am getting issues with Unknown provider when I am ...
1
vote
1answer
19 views

Unit-testing - TypeError: 'dict' object is not callable

I am new to databases in general, so sorry if this question is too basic. I'm trying to test a Playlist model which has a relationship with a Track model. class Track(db.Model): """ Model ...
0
votes
0answers
24 views

method for unit test

I want to test a method with unit test for the following class and want help on how to write the unit test for the valet alert method public void onCreate() { mPreferences = ...
1
vote
0answers
15 views

Trying to convert this Mockito test to Mockk results in error

Having issues with the following conversion from Mockito to Mockk. So I have this @Mock private lateinit var loginLiveDataObserver: Observer<LoginResult> val inOrder = inOrder(...
0
votes
0answers
9 views

Compare UIColor in ObjectiveC Unit Test [duplicate]

I created a unit test to verify the background color into UITableView. The default background color to UItableView is white. When executing the test. This test Failed and this is the message (...
0
votes
1answer
7 views

Mock Third party library (Razorpay) in Angular Unit tests?

I am trying to test a function in one of my component which consists following two lines: this.rzp1 = new Razorpay(orderDetails); this.rzp1.open(); I am trying to understand how to mock Razorpay in ...
-1
votes
0answers
14 views

unit testing a post service with karma jasmine angular 7

I have written 2 unit tests for my service where I am treating this service as a get which seems to work (the tests result in sucess) but I want to pass an argument to my service, my service is ...
0
votes
0answers
22 views

Build error for DB unit test project in VS2019

I recently got a brand new workstation and installed VS2019 on it. Previously, I was on VS2017 and working with db unit test project. Now when building our SQL Server database unit test project in ...
0
votes
0answers
7 views

Karma conf: Uncaught SyntaxError in Chrome Headless

I am getting the following Chrome Headless error (React 16). My package.json has all the karma plugins for chai, mocha, sinon, webpack, Chrome-launcher. cross-env NODE_ENV=test karma start karma.conf....
0
votes
0answers
53 views

How to unit test CRUD (Retrieve)?

Brand new both to .net core as well as for unit testing, so please be at my help pointing out where the problem lies in my code. [TestMethod] public void ...
0
votes
0answers
9 views

ExtJS Unittesting Pakages Independently

In my application I'm using https://github.com/karma-runner/karma for unit-testing. Now, I've a requirement where I've to write and execute packages(Which are in my application) independently. What ...
2
votes
2answers
46 views

How to test Go code with filepaths defined as constants

I'm writing tests for a project of mine, which involves fixed filepaths and base URLs. To me, the most logic way to define them is by means of public/private constants in a relevant module, but that ...
-4
votes
0answers
30 views

How to implement junit coverage with jacoco in ant build?

I have written junit test cases. Can someone help me on how to set up jacoco for ant build with steps or provide some links for the same. Thanks in advance.
1
vote
0answers
17 views

ScalaPlay > 2.6 how to access POST requests while faking a trivial server in tests

I'm trying to setup a fake server with Play2.7 and the environment suggested by https://developer.lightbend.com/guides/play-rest-api/ just echoing json from a POST request. While I was able to make ...
0
votes
1answer
36 views

Golang: how to generate a net/http timeout Error to perform unit test

I got a piece of code like below: if timeoutErr, ok := err.(net.Error); ok && timeoutErr.Timeout() { // Some code that need to test } How could I generate a error that can match the ...
0
votes
0answers
19 views

Jest: setTimeout is being called too many times

I am testing a react component that uses setTimeout. The problem is that Jest is saying that setTimeout is called even though it clearly isn't. There is a setTimeout to remove something from the ui ...
0
votes
1answer
11 views

console.log unit test failing under mocha with unknown error

My unit test failing for following code.when I run test i see below result with unknown error.I am not getting how to test second parameter paylod in console.log method. Test console log() -----------...
-1
votes
0answers
21 views

jdbcTemplate Mockito unit testing

I'm trying to perform unit testing and write a test for jdbctemplate.query. I need the code coverage for the below method. Code: ` public List<User> UserInfo(final Long runId){ ...
0
votes
1answer
41 views

kotlin - Room database error when unit testing

I am trying to write a unit test for my database, but I am getting the following error. The error says that should not be a null value. Through the Log.i, I can know if variable count is a null value....
2
votes
1answer
35 views

Mock an IList.Add using Moq

I'm trying to setup a moq object to run some unit tests against the business layer object which uses EF6. So far I can test simple methods invocations and check whether those methods were called. But, ...
1
vote
0answers
30 views

How to test Rest API endpoint which takes value from constantly changing external API

I use external API, which returns list of sorted by date Objects with many (approx. 30) properties. I wrote simple Rest API using Spring Boot with one endpoint /newest_obj_name which just return ...
0
votes
1answer
39 views

Selenium - System.ArgumentNullException: text cannot be null Parameter name: text

When I am trying to run the code then I get this error "System.ArgumentNullException: text cannot be null Parameter name: text" it doesn't pull the data from excel file; can anyone please give me the ...
0
votes
1answer
37 views

How can we measure the performance of azure search suggest API for 100 concurrent users?

I have implemented autosuggestion feature in my application and I am using azure search suggest service for providing suggestion. It's working fine for me but I am not sure what will be the impact ...
0
votes
0answers
27 views

I can't set ActivatedRoute in unit testing

I have a function which I test has many if conditions and switch statements which depend on ActivatedRoute values. I need to set a not subscribed ActivatedRoute in unit testing in angular to be able ...
1
vote
1answer
135 views

Angular Service Member Variable Not Accessible in Unit Tests

I am trying to test my Angular service, and part of what the service does is load a JSON file that is used as configuration for the service. I have confirmed in the tests (through console.log) that ...
1
vote
2answers
17 views

Mock class prototype in javascript with jest

I am currently on a project and i need to mock a certain constructor class prototype to run test so it doesn't deal directly with my database. I already tried researching and discovered i need to ...
1
vote
1answer
26 views

verification for unit tests failed

I am trying to test a class for a valet alert service but I am having a problem in verification of the test and getting this error whenever I try to verify my method public void ...
0
votes
0answers
23 views

Define Unit test run

I have a method that throws an exception and I would need to bypass a line: private void Method(float normPos) { this.objA.SetActive(false); this.objB.SetActive(true); this.containerRt....
0
votes
2answers
30 views

karma configuration to disable headless chrome and use only terminal

I am trying to run Angular unit test. I want to configure karma.config file not to open headless chrome. Simply I want to see output in terminal alone. I tried by commenting below code lines in karma....
0
votes
0answers
6 views

setData of vue-test-utils not re-updating the component

I'm using vue-test-utils with jest, I have router-link being rendered in a Login Component. I'm passing router to the component as well. There is data called 'email', on its update forgot link get's ...
0
votes
4answers
50 views

How to unit test a method that changes reference of a private field

I'm writing unit tests for a class in a game of life application. I have a method which creates a 2d array of bools and then changes the reference of a field (another 2d array of bools) to the new ...
0
votes
1answer
25 views

how to unit test router.navigate in angular app

I am running unit test for angular app, I want to unit test if navigation is working correctly in angular app. if (this.customer.length == 0) { this.router.navigate(['/nocustomer']); } And ...
-1
votes
2answers
26 views

Mock call to static method of a utility class

I need to write a unit test for the method processNotification. But this method internally calls JsonUtility.getNotificationDTOFromMessage. I need the return value to be null when this is called. ...
-2
votes
1answer
15 views

Testing practice an API wrapper without using unittest module

i have wrote an api wrapper which has around 70 endpoints. To test them all https://paste.ubuntu.com/p/V6mkK4dSdh/ i have wrote this script without actually usign the unit testing module. Is it a ...
1
vote
0answers
38 views

How to mock a python function inside another function

I have the following function in script.py: from mock import patch def outer(): def inner(): # something here return 5 return inner() + 2 print(outer()) # 7 To test the ...
1
vote
2answers
38 views

react-testing-library | Cannot Split Test into smaller chunks inside describe method

I'm learning about unit testing React components using react-testing-library I have the component rendering correctly, however, when I aim to break the test into smaller chunks inside a describe() ...
1
vote
1answer
24 views

Why are my tests passing with conflicting assertions? [on hold]

I am new to Python/Pytest and I'm trying to understand mocking/patching. I am currently adding tests to an existing codebase and am having a lot of trouble with these concepts. I spent several hours ...
-1
votes
0answers
13 views

Why am I getting an AssertionError during unittesting?

i am testing some test in django and i got an error How can i solve those error!! This is django 2.1.7 (venv) C:\Users\hp\myblog\myblog>python manage.py test Creating test database for alias '...
1
vote
1answer
28 views

Swift unit testing: module name of object class causes type check to fail

I've had unit tests in my project for a couple weeks and they've been working fine up until now. One of my new unit tests instantiates one of my custom view controllers. Said view controller ...
0
votes
1answer
34 views

NotAMockException when calling static mock in Scala

I am trying to use PowerMockito in Scala to bypass a call to scala.io.Source.fromURL, which is a static method in the class Source. I have gotten very close to getting this to work, but I keep getting ...
1
vote
0answers
17 views

Why PowerMock runs private method when I call verifyPrivate?

I'm testing some methodA which has another one inside and I need to check that that methodB has not been called due to return. If I run this test with debug, everything works correctly. But test fails ...
0
votes
0answers
12 views

How Can I Test My Component's Methods When Using Connect() and PrefetchResourceContainer

I am trying to test for componentDidMount(). When I try to mount my component I receive a null instance. When I shallow render it, componentDidMount is never called because I can't mount it. My Code: ...
2
votes
1answer
39 views

How to mock a keypress in test method?

I wrote a game of life console application and now I'm writing unit tests for it. The game board is rendered in a loop that can be broken with Esc press. I do not know however how to simulate that ...
1
vote
0answers
32 views

Verify mocked method call with lambda?

Using Mockito, I'd like to verify a mocked method call (particularly the parameters passed to it) via a lambda, without having to use a Captor, etc. MyThing class MyThing { public void run() { ...