Skip to main content

New answers tagged

0 votes

Test method is inconclusive: Test wasn't run. Error?

The projects in my solution were all in .NET 6, but I didn't have the .NET 6-sdk installed, but only the .NET 8-sdk. Installing the .NET 6-sdk solved the issue. Looks I have some upgrading to do...
Natrium's user avatar
  • 31.3k
Advice
1 vote
0 replies
0 views

How can I tell Shouldly to ignore the concrete type of collections when comparing objects?

You’re not doing anything wrong — this is just a limitation of Shouldly. ShouldBeEquivalentTo compares concrete types, not just structure. So even though both List<T> and ReadOnlyCollection<T&...
prvit's user avatar
  • 1,011
0 votes

DataTestMethod and DataRow attributes in MSTEST

The accepted answer is now obsolete. As per the following MS Learn document, the [DataTestMethod] attribute is deprecated and will be removed in a future version of MSTest. Use the normal [...
Simon Elms's user avatar
  • 20.4k
Tooling
0 votes
0 replies
0 views

How to unit test SQL Server User-Defined Table Types against C# classes to ensure property order and compatibility?

You don't specify how you are creating DataTable s but assume it is using reflection e.g. FastMember library. Why not create a custom attribute to store column position (e.g. "Ordinal") and ...
Alex's user avatar
  • 5,222
0 votes

Swift XCTest unit tests in a MacOs Command Line Tool project

Preliminary remark: Having the same problem, I tried to solve it following a dozen of webinars and articles on XCTest without success. The comments of this question finally solved the problem. I ...
Christophe's user avatar
  • 75.1k
Advice
1 vote
0 replies
0 views

How to Test Builder Pattern that Returns an Object with No Accessors?

Don’t waste time writing unit tests for code that everybody can recognize within a few seconds as being correct (or too trivial to be incorrect). Focus on test cases for the actual execution of the ...
Holger's user avatar
  • 302k
Tooling
1 vote
0 replies
0 views

How to unit test SQL Server User-Defined Table Types against C# classes to ensure property order and compatibility?

You can always connect with an account used for read-only access to the DB. It is a double-edged sword in my experience as I have been in environments where the SQL scripts created fall out-of-sync ...
bdcoder's user avatar
  • 3,998
Tooling
0 votes
0 replies
0 views

How to unit test SQL Server User-Defined Table Types against C# classes to ensure property order and compatibility?

Unit testing a database connection and general questions on database-dependent code and unit testing But then does it matter what you call it - if it mitigates a risk for you then job done?
Dale K's user avatar
  • 28.3k
Advice
0 votes
0 replies
0 views

How to Test Builder Pattern that Returns an Object with No Accessors?

Thanks for pointing out the signatures not being clear. I corrected the build() method on the AddCommandBuilder to return an AddCommand instead of a AddCommandBuilder.
hooknc's user avatar
  • 5,005
Tooling
0 votes
0 replies
0 views

How to unit test SQL Server User-Defined Table Types against C# classes to ensure property order and compatibility?

Is using a database connection in a unit test bad practice? Or am I wrong? I say this out of ignorance.
Dilan Felipe Bernal Castaño's user avatar
Advice
0 votes
0 replies
0 views

How to Test Builder Pattern that Returns an Object with No Accessors?

Whoever wrote that class is really trying to make things hard for everyone. The right way to do this is to convert AddCommand into a record and simply assert the values. If you're on an old JDK that ...
Torben's user avatar
  • 3,955
Tooling
1 vote
0 replies
0 views

How to unit test SQL Server User-Defined Table Types against C# classes to ensure property order and compatibility?

I'm using EF Core for managing my database schema. Which doesn't have any support for UDTT. So I built my own. I define each UDTT based on an EF Core keyless entity type with an added [SqlType] ...
Jeremy Lakeman's user avatar
Advice
0 votes
0 replies
0 views

How to Test Builder Pattern that Returns an Object with No Accessors?

and verifying that execute() returns a valid Source object.
Marce Puente's user avatar
  • 1,198
Tooling
0 votes
0 replies
0 views

How to unit test SQL Server User-Defined Table Types against C# classes to ensure property order and compatibility?

You're on the right track. Use SQL Server as the single source of truth and avoid exporting and parsing SQL files, i.e. read the column names and order, for example: public sealed record UdttColumn(...
bdcoder's user avatar
  • 3,998
Advice
0 votes
0 replies
0 views

How to Test Builder Pattern that Returns an Object with No Accessors?

By checking the return value of build? (The signatures don’t make sense though.)
Dave Newton's user avatar
Tooling
1 vote
0 replies
0 views

How to unit test SQL Server User-Defined Table Types against C# classes to ensure property order and compatibility?

Have you considered querying the database itself to compare the type definition against the C# type? e.g.: SELECT sc.* FROM sys.columns sc JOIN sys.table_types stt ON stt.[name] = N'DefinedType' AND ...
AlwaysLearning's user avatar
0 votes

How do I keep Visual Studio deleting the Deploy directory at the end of MSTest run

According to Microsoft documentation on the .runsettings file, this behavior can disabled via configuration. Add a file named .runsettings as a solution item or a project item with the following ...
Dan Stevens's user avatar
  • 6,880
Best practices
0 votes
0 replies
0 views

Testing with corroutines

The parameters First, as a code style requirement, such a class should take a CoroutineScope parameter, not a CoroutineContext. CoroutineContext is used in APIs when it will be appended to an existing ...
CLOVIS's user avatar
  • 1,078
0 votes

How to mock ResizeObserver to work in unit tests using react testing library

We had similar issues in our environment. The cleanest solution in our vitest environment - add code to test-setup.ts as follows: const ResizeObserverMock = class { observe(): void { // void } ...
bob.mazzo's user avatar
  • 5,819
2 votes
Accepted

NSubstitute: ToDictionaryAsync: Only sources that implement IDbAsyncEnumerable can be used for Entity Framework asynchronous operations

The tested code was using the wrong extension: ToDictionaryAsync from System.Data.Entity instead of ToDictionaryAsync from Microsoft.EntityFrameworkCore
heringer's user avatar
  • 3,317
Best practices
0 votes
0 replies
0 views

Do anyone's know how to mock supabase in Flutter?

The core problem isn't Flutter-specific. Supabase's query builder is a fluent chain (.from().select().eq().single()), so your mock has to be chainable too. The fix is two things: dependency injection ...
Dusty Mumphrey's user avatar
Best practices
1 vote
0 replies
0 views

What are best practices for unit testing with Jest in JavaScript?

It's up to you how to structure it. Jest is configured by default to use __tests__ directory or spec/test file suffixes. For unit tests, it makes sense to use prefixed files for 1:1 match with tested ...
Estus Flask's user avatar
Best practices
0 votes
0 replies
0 views

What are best practices for unit testing with Jest in JavaScript?

When should I mock something vs just using the real implementation is general and not specific to JavaScript etc. Have you looked into that at all? Should you aim for 100% code coverage? It sounds ...
ADyson's user avatar
  • 63.1k
0 votes

Mocked service throws NG0201: No provider found for `_HttpClient` error

This usually happens when you transitively use a service, which isn't provided in the file under test. In the case of the missing HttpClient, the easiest way is typically to provide the service itself ...
Zaphoid's user avatar
  • 2,828
0 votes

ExpectedExceptionAttribute is not working in MSTest

Try the new way Assert.Throws<ArgumentNullException>(() => throw new ArgumentNullException("test"); );
Walter Verhoeven's user avatar
0 votes

Run Django tests in the VSCode Test explorer?

I tried to follow Benoit Blanchon’s answer, but the linked documentation has not helped me, because my project does not contain manage.py. I succeeded with the following steps: Install pytest-django ...
Melebius's user avatar
  • 6,813

Top 50 recent answers are included