Category "unit-testing"

Angular/Jest - Test that the subject has thrown error after setter is called

I have a class that is responsible for setting the theme for my application. I'm trying to test that it throws an error if you give it a theme that it does not

Injecting a Mock using registerConstructor

I've successfully set up a Mock for injection via fruit using .replace(get*Component).with(getMock*Component) like so: #include <gmock/gmock.h> #include

TypeError: (0 , _axios.default) is not a function when use jest.mock('axios') inside a *.test.js file

I try to mock axios module inside my test file like this // mycomponent.test.js import axios from 'axios'; jest.mock('axios', () => ({ get: jest.fn(() =&

TypeError: (0 , _axios.default) is not a function when use jest.mock('axios') inside a *.test.js file

I try to mock axios module inside my test file like this // mycomponent.test.js import axios from 'axios'; jest.mock('axios', () => ({ get: jest.fn(() =&

Grab object values during runtime for creating Mock objects required for writing Unit Test

Consider the below class which needs to be tested, class ToBeTested { Employee _e; public ToBeTested(Employee e) { _e = e; } void Process() {

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 with java9 ?) thi

Mocking a object using powerMockito.whenNew() and using doNoting(object) but locally created object is calling actual method

public class A { public String[] processMessage(Message msg) { public boolean A(msg) { Utils utils = new Utils(); utils.meth

Why does Android Studio say "Test events were not received"?

I'm trying to unit test in my android application, and this is the simple test tutorial what i'm doing. import static org.junit.Assert.*; import org.junit.Test

How to query by text string which contains html tags using React Testing Library?

Current Working Solution Using this html: <p data-testid="foo">Name: <strong>Bob</strong> <em>(special guest)</em></p> I

xunit test for IFormFile field in Asp.net Core

I have an Asp.net Core method with below definition. [HttpPost] public IActionResult Upload(IFormFile file) { if (file == null || file.Length == 0)

C# custom mail server: receive email through socket on local machine

I'm writing unit testing for email validation. I'm trying to write a very simple POP3 email listener (using sockets) so the email can be sent to my local machin

Unit testing Flask Babel translations

I'd like to do some unit tests to check my flask app translations. I have tried this piece of code: def test_pt_br(self): with app.test_request_context():

Mock redis template

I am facing a issue in mock redis template. Can any one help me to write unit test for below class. @Repository public class CasheRepo { @Autowired pr

Disable Coverage on Untested Files - Jest

When using @vue/cli-plugin-unit-jest, I am receiving coverage reports each time I run my unit tests, regardless of whether I have the --coverage flag in the exe

Is it possible to mock a function imported from a package in golang?

I have the following method to test, which uses a function imported from a package. import x.y.z func abc() { ... v := z.SomeFunc() ... } Is it

How do I write a Rust unit test that ensures that a panic has occurred?

I have a Rust function that panics under some condition and I wish to write a test case to validate whether the function is panicking or not. I couldn't find an

how to set up postgres database with pytest-django?

I would like pytest-django to install a Postgres extension when it creates a test database. I've been mucking with conftest.py to try to get this to work, but

What are assertions in JEST?

It's documentation says that while dealing with async code, expect.assertions(x) should be written. What exactly do assertions refer to? Is it a term of plain J

Spring Boot - Test for controller fails with 404 code

I want to write a test for controller. Here is test snippet: @RunWith(SpringRunner.class) @WebMvcTest(WeatherStationController.class) @ContextConfiguration(cla

React-testing-library: changes due to input

I'm trying to test that a component updates as it should due to changes in an input element. I use the fireEvent.change()-function, and if I then check the valu