How do i "run" a dbunity test? - dbunit

I am relatively new on unity testing and just started working with dbUnit.
I wrote a test class, along with the test methods.
However, I have't figured out yet how to "run" my test case class. How can I do that? I mean, how do I execute my test methods and collect the results?
Thank you,

First of all look here: https://stackoverflow.com/a/34716990/5719185 - it is how to prepare dbUnit tests.
And you also need to mark folder with tests, but before this look here (about project structure): https://stackoverflow.com/a/28161314/5719185
After this you can choose Run in the tests class (right click in your class), or you can execute your tests with Maven, for example with clean-install.

Related

Why does xcode not have an option to create tests anymore?

As of today, I can no longer create projects with unit tests in Xcode. Normally it looks like this:
As of today it looks like this:
How to I get back the option to create unit tests? I can kind of manually create unit tests, but they don't work with CMD-U, can't find objects unless they're explicitly imported, and cause either linker errors or EXC_BAD_INSTRUCTION when run.
Figured it out. You can create a project with unit tests for any kind of project type EXCEPT "Command Line Tool".
So if you want to have unit tests with your command line tool, best to create it as a framework project with unit tests, then add source files to both the framework (for the unit tests) and to your command line tool. Awkward and clunky, but it works.

Running Visual Studio Load Test From Build Definition

I created a build definition that runs automated tests using MTM build environments and test suites. I recently created a Visual Studio Load Test, which can be added to a test suite just like any test method marked with the [TestMethod] attribute. However, when I run the build, I get no errors and it appears the aggregate tests don't run. Is there a way to make this work?
I found this article: https://blogs.msdn.microsoft.com/testingspot/2013/01/22/how-to-automatically-run-a-load-test-as-part-of-a-build/ which describes a way to do it, but I can't find a build template that matches what he describes, and it appears this only allows you to run a single load test.
Also, when you configure a test controller, there is an option to configure it for load testing, but to do this, you must unregister it from the Team Project Collection. If this is done, it appears the controller can no longer be used in an environments to run project automated tests. This defeats the purpose of what I want to do and makes it seem that Load Tests and Team Projects are mutually exclusive. Is this the case? If so, this is a big oversight. Load tests are the kind of thing you would like to run automatically. Thanks for the help.
You are unfortunately right. A test controller used for load testing cannot be used for other automated test execution 'at the same time'. In your scenario I would recommend that you setup a different test controller and agent for load testing and you would be able to queue it as a part of your build to achieve what you are looking for.
There is no special build process template for this case.

Running MSTest tests from C#

Is it possible to run all tests of a TestClass class using C# code only ? I found that it is possible to run tests using a command line tool called MSTest, but this is not what I am looking for.
I want to run all tests defined in a class, change some parameters and run all tests again. This would be repeated a few times, so it would be nice to do it using C#, as it would be easy to evaluate the test results programmatically.

Is there a way to disable/ignore a Load Test in Visual Studio 2010 without using Test Lists?

I'm new to load testing in Visual Studio/MSTest, and I created a new Load Test recently to validate some high-traffic scenarios for a WCF service. I want to add this to the tests project for the service, but I don't want the test to be executed whenever I "Run All Tests in Solution" nor as part of our Continuous Integration build-verification process because a) it takes 5 minutes to run, and b) the service call that it is testing generates many thousands of email messages. Basically, I'd like to do the equivalent of adding the [Ignore] attribute to a unit test so that the load test is only executed when I explicitly choose to run it.
This MSDN Article ("How to: Disable and Enable Tests") suggests that the only to disable the test is to use Test Lists (.vsmdi files), but I don't have much experience with them, they seem like a hassle to manage, I don't want to have to modify our CI Build Definition, and this blog post says that Test Lists are deprecated in VS2012. Any other ideas?
Edit: I accepted Mauricio's answer, which was to put the load tests into a separate project and maintain separate solutions, one with the load tests and one without. This enables you to run the (faster-running) unit tests during development and also include the (slower-running) load tests during build verification without using test lists.
This should not be an issue for your CI Build Definition. Why?
To run unit tests as part of your build process you need to configure the build definition to point to a test container (usually a .dll file containint your test classes and methods). Load tests do not work this way, they are defined within .loadtest files (which are just xml files) that are consumed by the MSTest engine.
If you do not make any further changes to your CI Build definition the load test will be ignored.
If you want to run the test as part of a build, then you need to configure the build definition to use the .loadtest file.
Stay away from testlists. Like you said, they are being deprecated in VS11.
Edit: The simplest way to avoid running the load test as part of Visual Studio "Run All" tests is to create a different solution for your load tests.
Why don't you want to use Test Lists. I think is the best way to do that. Create different Test Lists for each test type (unit test, load test...) and then in your MSTest command run the Test List(s) you want:
MSTest \testmetadata:testlists.vsmdi \testlist:UnitTests (only UnitTests)
MSTest \testmetadata:testlists.vsmdi \testlist:LoadTests (only LoadTests)
MSTest \testmetadata:testlists.vsmdi \testlist:UnitTests \testlist:LoadTests (UnitTests & LoadTests)

How do I run a specific test within junit

We have several junit test cases in a particular file, how do I run a certain test alone.
Note: I am aware of the #Ignore annotation, but don't want to use it. Since you will still have to mark the rest of the use cases with the #Ignore option.
You can specify the test you would like to run via the -Dtest= parameter.
Just run it with this parameter values:
-Dtest=TestClass#singleTestCaseMethod
It is only supported in JUnit 4.x. More information: Running a single test
This depends on how you're running the tests.
If you're using Eclipse, you can either select the name of the method in the Java Editor and press F11/ctrl-F11 to Run As JUnit. This also works if the cursor is on the method name itself.
If you've already run the tests, and the JUnit view is open in Eclipse, you can rerun a particular method by right clicking on the test and selecting Run/Debug. There will be similar functionality in Intellij.
If you're running from the command line, you can use JUnitCore.
java org.junit.runner.JUnitCore TestClass1 TestClass2
EDIT: For maven, you can specify the name of the method on the command line:
mvn -Dtest=TestCircle#mytest test
See the documentation for Maven Surefire - Running a Single Test.
In IntelliJ (You should try the free community edition, I tried several IDE and I found IntelliJ to be the best, far ahead the competition), you press CtrlshiftF10 to run unit tests. The location of the cursor will decide what to run: if it's within a test, it will run this test only, if it's outside, it will run all the tests on the current class.
And shiftF10 will re-run whatever was last ran.
You can also right-click on the Run view to re-run any specific test.

Resources