Questions tagged [unit-testing]

-1 votes
0 replies
How to Mock django chained queries using python unittest
func_to_test.py from models import MyModel def myFunc(): #Query 1 queryset_exists = MyModel.objects.filter(id=0).exists()) #Query 2 que...
asked 4 months ago
0 votes
1 replies
Jasmine testing stateful service
I am new to Jasmine testing and looking for a "best practice" for unit testing a stateful AngularJS service. Most tutorials I could find focus on...
0 votes
1 replies
Debounce function unit test
I am using a debounce function inside componentDidMount like so: ... if (setNavigationSections) { setNavigationSections(filtered...
asked 4 months ago
-3 votes
0 replies
Please explain the angular code coverage report [on hold]
I am trying to understand the angular code coverage report. What do the different attributes stand for with respect to the actual code - statemen...
asked 4 months ago
0 votes
0 replies
Jenkins test results behaviour
I am new to Jenkins and of late I observed that in one of the job when i build application test results are changing even though new changes are...
-1 votes
0 replies
How to test change in color of an element on mouse hover in Angular unit testing using Jasmine?
I would like to check the color change when a mouse hover happens on an anchor tag. The color of its text is #333333 and on mouse hover it will b...
0 votes
0 replies
Spring / JUnit tests - Handle multiple transaction per test
I'm new to Spring Boot Testing and not sure if it's even correct how we are using it. We are using Spring Boot 1.5.8.RELEASE including JUnit 4.12...
1 votes
1 replies
How to mock generic method with delegate parameter
In a abstract class I have a virtual method with this signature. public virtual async Task<TResult> MethodAsync<TParameters, TResult>...
asked 4 months ago
1 votes
1 replies
Cannot add a unit test to a .NET Core Unit Test Project VS2017
If I Add a New "MSTest Test Project(.NET CORE)" to my solution, then right click the newly generated projected goto "Add" > "New Item" the "Ad...
10 votes
2 replies
Get declared fields of java.lang.reflect.Fields in jdk12
In java8 it was possible to access fields of class java.lang.reflect.Fields using e.g. Field.class.getDeclaredFields(); In java12 (starting wi...
asked 4 months ago
0 votes
1 replies
Restsharp: IRestResponse content returns “[]”
I am trying to implement a test of my rest api using restsharp, which seems to be a very powerful and easy tool to use for simple tests. With th...
asked 4 months ago
0 votes
2 replies
How to mock a function in jest or prevent default?
I am trying to use react-testing-lib to do some integration testing I want to mock a function like inside my react class called handleSubmit ha...
0 votes
0 replies
C++ Unit test - Good practice? [closed]
I only used C++ in a C style and recently I am learning good practices in C++. My question is regarding unit test in C++. Why Boost.Test or CPP-U...
asked 4 months ago
-2 votes
0 replies
Unit Test Cases
I am an android developer working on kotlin unit test cases and have a function class ExpiryDateValidator @Inject constructor() { var isValid =...
asked 4 months ago
1 votes
1 replies
There is no directive with “exportAs” set to “cdkStep”
I get this error from karma/jasmin in my spec.ts: There is no directive with "exportAs" set to "cdkStep" <!-- Step 1 --> <cdk-step...
1 votes
0 replies
How to write unit test for subscribe callback of a service
I am learning about how to write unit test in Angular. I create a httpService having method sendToServer. Every component uses it to send reques...
asked 4 months ago
0 votes
0 replies
treeModel undefined when test angular-tree-component
I am working with angular-tree-component to show a category tree in a stateless component in angular. Currently, I have up and running the compon...
asked 4 months ago
-1 votes
0 replies
How can I do a unit test using vb.net?
I am trying to do a unit test using the following code but I can not do it. Would you like to check it out and give me a guideline. Cheers Publ...
asked 4 months ago
0 votes
1 replies
Mocking Angular Material Dialog afterClosed() for unit test
I am opening my mat-dialog with the following function: accept() { let dialogRef = this.dialog.open(AcceptDialogComponent, { data: { has...
-1 votes
1 replies
Running a unit test module in Python
I have a unit test. It's name is test_mymod.py Snippet: ... import mymod import os import unittest class myTestCase(unittest.TestCase): de...
asked 4 months ago
0 votes
0 replies
Not able to import InstantTaskExecutorRule in my 'jUnit' test case even after adding 'core-testing' dependency - Android testing
I am writing test cases for my LoginViewModel. Where I want to perform setValue() operation on my MutableLiveData. To avoid Method getMainLooper...
0 votes
0 replies
Pact Testing PactProviderRule not detected
I am starting with Pact test, and I followed the example from Pact-JVM-Example, then I created my own test The Producer returns, the data from a...
1 votes
1 replies
How to unit test a button within an ngfor
I have a button within a nav tag, which is rendered by looping over a list <nav *ngFor="let test of getTests(); let last = last"> <...
asked 4 months ago
-1 votes
0 replies
Why I don't need to use a 3rd party lib like rewiremock to rewire and mock dependencies with jest? [duplicate]
In this question that I asked here: Why does mutating a module update the reference if calling that module from another module, but not if call...
asked 4 months ago
1 votes
1 replies
Unit testing 'pathlib.Path.is_file' in Python 3.x
I am new to unit testing in Python and have problems to get my tests running. I want to implement the following test class as shown in here: http...
asked 4 months ago