I get an error like this when writing unit test
My product class is like this. I added virtual.
My map is like this.
SqlServerHelper like this.
I am using vs code 2022. I'm developing with Net 6.0 entity framework.
I am getting this error while doing unit test. No errors in codes.
Is it a problem with the version? Or Is there a logical error.
what is the solution?
Problem solved.
I wrote Db link instead of Northwind Context. :)
Related
So I can test code that uses a database using PHPUnit, I just installed the DbUnit extension using Composer, and I get the following message:
Package phpunit/dbunit is abandoned, you should avoid using it. No
replacement was suggested.
I've seen the issue on the extension being abandoned, and people talk of rolling your own database testing code, but they don't go into any more details. Is there a recommended way to test database code using PHPUnit, or does anyone know of any examples?
(I did open an issue and asked the author of PHPUnit this, but his reply was quick and to the point - "No, there is not.") :-/
I'm currently running into the following problem:
We introduced Unit-Tests into our native c++ application by using the native microsoft unit test framework included in Visual Studio 2015 Microsoft::VisualStudio::CppUnitTestFramework.
To start the unit tests inside visual studio we use the Test-Explorer as can be seen in image 1. By adding a method attribute to a Test-Method (as shown in image 2) the Test-Explorer allows to sort and filter by attribute (as can be seen in image 3).
All this works without a problem. We started having a problem when we tried to implement these unit tests into our continous integration system (CI).
To start Unit-Tests from a console we use vstest.console.exe, which is located in: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe. The official documentation can be found Here.
The following screenshot shows how the tests succeed when using the console:
Adding a logger and outputing files to .trx works well too. What does NOT work however is applying a filter to determine tests with specific attributes. According to the documentation something like that should be possible by using the /TestCaseFilter:-switch. The following screenshot however shows the resulting error:
It translates to: "No tests matched the filter because it contains one or more properties that are not valid (TakesLong). Specify filter expression containing valid properties (TestCategory, Priority, FullyQualifiedName, Name) and try again."
Does anybody know this problem or has an idea on how to fix it? Ultimate goal is to be able to exclude certain tests (Take very long / need a hardware dongle etc.).
Best regards, LorToso
I ran into this problem too, and sadly it looks like we're just out of luck. vstest.console.exe only supports a limited number of filters for both C++ and C#.
The approach I think I'm going to move towards is to segregate tests into different modules so I can run unit tests for nightly and CI builds and integration tests (like needing a database) only for releases.
Alternatively, you could split them up by namespace in the same module and use the FullyQualifiedName filter. Unfortunately, there is no '!~' condition either so you might have to work around that somehow.
I have a large preexisting code base depending on many external libraries which all uses \MTd as the runtime setting. This code base is stable and well tested in this configuration.I would prefer to keep it as is.
I am attempting to integrate a new external library into the code base (incase it matters it is the Casablanca REST SDK) however I have just discovered it appears to need to be used with the \MDd setting. I was getting some strange untrackable bug deep in std:shared_ptr when I discovered this problem. When I changed my isolated project to use \MDd casablanca worked much better.
Visual studio does not appear to allow me to have different settings it appears to be either all or nothing in one solution?
Does anyone know of a good work around for this situation? Any suggestions? I'm not even sure where to focus my attention?
1) Can I fake Visual studio out and use both? and if so should I actually do that?
2) Or should I attempt to get a working static library of casablanca? It does not appear possible on the disscussion forum?
3) Or should I just bite the bullet and move the entire solution to \MDd?
4) Lastly, should I just cut my loses and try a different client server framework? A quick search showed for a windows c++ client server solution I could use Boost Asio, Google Client API, WinSock?
This is my first client server implementation and opinions are very welcome.
We actually moved the entire code base to link dynamically. There were other libraries causing some concerns and this seemed like a good time to migrate the code base. Problem solved, at least for now. Thanks for the feedback.
I have ported over some code from a Windows application to Monotouch.
It is using ASMX Web Services to talk to some API.
The code fails on Monotouch 5 because the method
System.Web.Services.Protocols.SoapHttpClientProtocol.GetWriterForMessage()
is never called.
I have seen that in Mono you will even get a NotImplementedExeption but not in Monotouch. It simply gets ignored.
I need to find a way around this. I have to add custom headers to make the solution work.
Any workarounds or maybe is there even a chance that this will be fixed soon?
(I also filed a bug report, but I'm asking here because I am desperately looking for a workaround).
EDIT:
I found kind of a workaround but it is very annoying to use.
In the auto generated reference file you will have to decorate each and every method with
[SoapHeader( "SessionKeyHeader", Direction = System.Web.Services.Protocols.SoapHeaderDirection.InOut )]
Then implement the custom soap header class but skip the GetXmlWriter() method.
A bug has been filed at Xamarin about this issue.
You know how they say, "There's an app for that"? Well, is there a VS plugin for this ................. ?
I want to be able to right click on a method and select "Create unit test method ..." and have it generate an nunit stub in a particular place in my project tree. So for example. I have a TheNextBigThing library with an Idea class and a MakeMeRich() method. I want to have it, for example, create a unit test method in my Tests project in a sub-folder named TheNextBigThing, in a class named IdeaTests.
I know. I know. All the TDD advocates will tell me I'm doing it backward, but humor me. I have some code I want to retrofit with some tests, and I sometimes write methods before tests.
If it doesn't exist, any pointers on how to write it myself?
If you are running Visual Studio 2010 Professional or Premium you have the option to create a unit test with MSTest by right clicking on the method.
Also, I would suggest using Pex. Pex will create the unit test for you, in addition to all unit tests needed to achieve 100% code coverage of a particular method.
It wouldn't be too hard to get the addin started. Since you have VS already, simply create new project > VS Extensibility. :)
You'll most likey have to learn some codegen unless you utilize a templating language of some sort.
Me? I think it's a cool idea and I'd like to see it implemented. Start it up, share it on github (or similar) and watch it grow.