Run dart unit tests in a flutter project - unit-testing

I have a flutter project that implements a classic client/server model to obtain resources across the network.
I'm writing a series of unit tests to test the core network actions.
As this is a flutter project, when I run the unit tests visual code launches the device simulator and installs an apk.
This is a slow processes.
These unit tests have no dependancies on flutter.
Is there some way that I can get the unit tests to run as dart cli unit tests to speed up start time?
I would prefer to not move the code into a separate project.

Related

How can we run C++ Unit Test in Github Workflow?

I am using Microsoft Unit Testing Framework. I have successfully created and used the tests to check the program. I want to create an assignment for students where the same test cases can run as a workflow so that the assignments can be checked on every push on Github repository. How to configure the workflow so that the workflow use the test file in the folder to run the tests?

Azure DevOps 'Run Only Impact Tests' doesn't work with XUnit Tests?

I have an ASP.net Web API project (.NET Framework v4.6.2) where I have written unit test cases using XUnit.
I have created a build pipeline in Azure DevOps with 'Run only impacted tests' set to checked. Also, my Visual Studio test version is set to *2.** in my test assemblies.
I have tried to run my mock tests (No data driven test cases) to check that only impacted test run but all the tests run.
I had hard luck finding the solution for It. Can anyone know how to do it right?
I have read this article and and done setting accordingly, but failed.

Running Xamarin unit tests on the target device

We are creating some unit tests to test our Xamarin C# code, and would like to run those unit tests automatically (Jenkins) on an actual target device (Android or iOS) connected to the Jenkins server, not an emulator. There are various unit test frameworks (Touch.Unit, XUnit, NUnit) to help generate a unit test application, but then I can't find a way to run those unit tests on the actual device without using Xamarin's Test Cloud (which we will use for our UI testing, but we'd rather do unit testing in-house).
Is there a command-line option to Xamarin Studio (Mac) to say "run this application on the specified device, and store the unit test output in the specified file"?
You can run Xamarin.UITests from the command line without Xamarin Studio and without Xamarin Test Cloud using NUnit. The NUnit command line runner allows you to specify the output path for the results.
You may need to modify the Xamarin.UITests so they use the device either by hard coding that information or by passing in the data somehow with say a file or an environment variable. There is also a PreferIdeSettings method which you can call in the UITest configuration. That would allow you to hard code the device information in the UITest but when running the UITests in the IDE it would use the IDE configuration.

Multiple test sets in Maven

I have written a REST server (in Java using RestEasy) with a unit test suite written in Scala. The test suite uses the mock server provided by RestEasy and runs with every Maven build.
I would like to create a second functional test suite that calls an actual tomcat server and exercises each REST service. I do not want this new suite to run with every build, but only on demand, perhaps controlled with a command line argument to Maven.
Is it possible to create multiple independent test suites in a Maven project and disable some from automatic running, or do I need to create a separate Maven project for this functional suite? How can I segregate the different functional suite code if these tests are in the same project with the unit tests (different directories)? How do I run a selected suite with command line arguments?
I never used it myself but I am aware of maven integration tests run by the Maven Failsafe plugin.
As the surefire plugin by default includes the tests named **/Test*.java, **/*Test.java, **/*TestCase.java the failsafe plugin runs the **/IT*.java, **/*IT.java, **/*ITCase.java tests.
Both test approaches have different intentions which seems to match part of your needs. It might be worth to have a look.....
Another approach would be to use maven profiles and specifiy different surefire includes for each profile.

Unit Testing and Web Apps - Resources

In a J2EE web application, how do people manage resources so that they are visible to both the web context and to unit/integration tests?
I find that often you end up having your source/resource folders configured a certain way during development (i.e., what Maven expects) and so your unit tests will run in your IDE. But once the web app is built and packaged into a WAR file (i.e., when your Continuous Integration server has done a build) your unit tests won't run anymore because the resources are located elsewhere.
Do you end up keeping resources in two different places and manually keeping them in sync?
We tried using unit tests in the container but gave up on it years ago. It's much better (for us at least) to make each unit test cover a single class and nothing else, mocking out the dependencies on other classes (see JMock or its many competitors). A good basic rule is that if it touches the database, network, or the filesystem, it isn't a unit test. (It may be useful for something else, but it isn't a unit test. See these unit testing rules for more on this.)
Unit tests written this way can be run anywhere, and they are blazingly fast (we have thousands and run them in under 60 seconds on medium-spec hardware.)
You may also want to run integration tests that check a subsystem or the whole application. We find that subsystem tests can also use mocking at their borders - for instance, we fake an external pricing feed - and that end-to-end tests work best with tools like Selenium or WebDriver, which let you deploy the whole application on a server and then hit it with a browser just like users do.
(By the way, our method of unit testing makes us mockists, rather than classicists, in Martin Fowler's taxonomy.)
Normally this is the reason for multi-module builds. The external services are in a separate build unit than the web application. So you build, package and run your integrations tests when you build that module.
Another module can contain your domain model and its unit tests, which are also run at build time.
It is quite common for a module that results in a WAR to not have any java code in it at all, but only web related artifacts. Although not necessary, this is often done because code that is in a war module cannot be included into another module.
The last special case is the module containing web-tests. This module may often need test-scoped artifacts from the other modules (because it is testing the application from the outside, but may need data from the inside). This can be solves by also packaging test-resources in jar files, creating a separate set of "test" jar files for each modules.
Multi module builds are the norm for maven projects, and are also easy to set up for other build systems like ant.
I won't package testing resources nor tests in a WAR file neither run unit tests from the WAR. Why you are trying to do so?