Category "unit-testing"

How to test database methods and get code coverage xUnit ASP.NET

I initially used the Moq library for testing, since I don't actually want to mess the data in my database. However, I quickly realized instead of running the co

Why is the Visual Studio 2015/2017/2019 Test Runner not discovering my xUnit v2 tests

UPDATE: Adding a 2019; the discovery/runner integration mechanism is same as per 2017 & 2015, so the key things that can go wrong are the

How can I create parameterized tests in Rust?

I want to write test cases that depend on parameters. My test case should be executed for each parameter and I want to see whether it succeeds or fails for each

Returning default mock results from actual objects' instances

Consider a scenario when you need to write integration tests for the REST API controllers. I use MSTest for this. The logic is following: Create new database, r

Returning default mock results from actual objects' instances

Consider a scenario when you need to write integration tests for the REST API controllers. I use MSTest for this. The logic is following: Create new database, r

gtest - testing template class

I want to test a template class with gtest. I read about TYPED_TESTs in Google Test manual and looked at official example they reference, but still can't wrap m

UnitTest JSONObject shows null

I have got a problem connected with JSONObject. @Test public void toUrlTest() throws JSONException { String url; JSONObject json = new JSONObject();

Moq with Unity Container unit testing

below is an example of production code that I am trying to unit test. I am struggling to resolve a dependency to a concrete class that is being used. public My

Is it possible to initialize the fixture only once and use it in multiple test cases?

Is it possible to have the fixture initialized only once and use it in multiple test cases within the same test suite? In the following example, fixture is cons

How can I configure Moq to return new instance per call?

I am trying to write a simple test with moq. When calling the mocked method for the second time, after changing the return value from the first call, the moq fr

How to unit-test a valuechange of mat-autocomplete filtered search result in Angular?

I use the mat-autocomplete functionality for searching in projects and want to test if entering a search string, which cannot be found in the project list, lead

TestNg - How to merge two dataproviders horizontally

Can you please let me know if we can merge the below 2 dataproviders public Object[][] dp1() { User user = new User(1L, "Arun"); Transaction trx = new Tr

Mockito verify unit test - Wanted but not invoked. Actually, there were zero interactions with this mock

At first I want to sorry for my english. I started to make some unit tests (i've never done this before, i'm a new guy in programming). I have to test simple

Intercept navigation change with jest.js (or how to override and restore location.href)

Application code is calling location.href = "some-url". I want to write a test that verify the navigation redirect has happened. Using jest on jsdom, I tried t

Android studio code coverage not showing any Kotlin classes

I have 2 Kotlin based AS projects. One works fine, the other doesn't. Both have an identical structure and gradle config. I'm using Kotlin 1.1.4-2 with AS 3.0b2

No tests found for given includes Error, when running Parameterized Unit test in Android Studio

I have tried to run Parameterized Unit Tests in Android Studio, as shown below: import android.test.suitebuilder.annotation.SmallTest; import junit.framework

Use Mockito 2.0.7 to mock lambda expressions

I want to mock a query provided on my repository like this: @Test public void GetByEmailSuccessful() { // setup mocks Mockito.when(this.personRepo.find

How to use go-vcr with githubv4 ? - getting httpClient Transport

Looking at the set up for go-vcr // Start our recorder r, err := recorder.New("fixtures/etcd") if err != nil { log.Fatal(err) } defer r.

How to assert parameter attribute sub-structures in PHPUnit mock call expectations

I am testing an parameter sent to a mocked event handler. The parameter is an object of "Event" sub-type, which itself has some data nested inside it. I want to

Error trying to create Mock.Of<ControllerContext>() for ASP.Net Core 3.1 Unit Test

As per last section of the Moq Quickstart defined here, I am trying to configure the following Mock in order to pass Form values to the controller method under