Category "unit-testing"

Android Studio - ActivityInstrumentationTestCase2 not found?

I am trying to unit test my MainActivty. My project cannot find ActivityInstrumentationTestCase2 and android.test package. I changed the target SDK to 27 to see

Assert two List have same subtypes in a certain order

I would like to check if two lists (let's say, ArrayLists) have exactly the same instance classes, based in an expected List. To do so, I have built the next me

Jest: ReferenceError: global is not defined

So I am writing unit test using "react-testing-library" on Jest and I have this error: Test suite failed to run ReferenceError: global is not defined

Ignore firebase related exceptions in Roboelectric unit test

My Roboelectric unit tests are giving this exception when I try to initialise Firebase in the Application class. java.lang.IllegalStateException: Default Fireb

Why does Pytest create a new class instance for each test method?

I was reading the Pytest documentation when I noticed a section titled "Grouping multiple tests in a class". There's a paragraph below with a caveat that each t

How to test multiple different type return value in unit test?

My code and test code are as follows: return two value, one is vector, and is boolean. Using command to test is ok. But in unit test it is in error. command tes

How to mock an environment variable that is referenced in an imported module?

I have created a file containing environment variables and I am writing a test for this file. The file ("my_variables.py") looks like: import os if os.getenv("

VectorCast vs GTest for unit tests

I am a newbie at VectorCast. I have developed some unit tests with VectorCast. But I am still not confident with VectorCast(maybe, I am wrong:) ). For unit test

Is it is possible to test only one function from component with Jest?

I have react component, for example something like this: const MyComponent = (props) => { const [state, setState] = useState(true); const {data} = useCon

How to run a test multiple times in Cypress.io

I have a test case to fix a bug that appears 1 in X times. I'd like to run the same test multiple times but I can't find any documentation that explains how to

Sinon.js combining calledWith number of times

I know with sinon.js you can test that a spy was called a certain number of times: sinon.assert.calledTwice(mySpy.someMethod); And you can test that a spy wa

Sinon.js combining calledWith number of times

I know with sinon.js you can test that a spy was called a certain number of times: sinon.assert.calledTwice(mySpy.someMethod); And you can test that a spy wa

PHP Startup: Unable to load dynamic library, when running unit tests

when I try to run my unit tests, I get this error PHP Warning: PHP Startup: Unable to load dynamic library 'bz2' (tried: \xampp\php\ext\bz2 (The specifie

Observe stdout from multiplatform kotlin commonTest code

I just want to see the output from a few simple println(...) in my Kotlin mulitplatform commonTest code. My build.gradle.kts looks a little like: import org.je

Angular/Testing unit: Failed: The pipe 'async' could not be found

When I run the ng test on this spec file it fail with this error: Failed: The pipe 'async' could not be found! I have tried to fakesync() the test and still the

How to test form controls avoiding bracket notation to preserve type checking and maintainability

The Problem My unit tests on a form break when I refactor an object's member because I can only access the formcontrols on a fromgroup by using bracket notation

Mock Retrofit error okhttp3.ResponseBody$1 cannot be cast

I'm trying to test a snippet of my code that uses retrofit, so I've created an interface to "mock" the return, it works in parts, it can invoke the onresponse o

How to test system that requires Time resource?

I want to write tests for system that moves entities and detects collisions, system uses Res<Time> to ensure that entities move with constant speed. I was

Vue Pinia function is undefined in onMounted when unit test is ran

I have a component and a Pinia store which contains a state and some actions. The code works perfectly fine in browser and in E2E (cypress) tests, but fail on u

Python: How to use mock or patch to check that a method inside another method has run?

I've read through a whole bunch of answers, but still don't understand where I need to mock and/or which class/module to patch and keep getting module does not