Maven package ignore Thread.sleep() in test cases - multithreading

I have Multimodule spring boot project where one of my modules has integration tests. In some test cases i called Thread.sleep because i am waiting for asynchronious operation to finish its job and check the result.
When i run the test class individually there are no problems. But after launching maven package and it comes to the step which execute tests these test cases does not work properly.
Any suggestions why this happens and how to fix it?
Perhaps this is going to happen if i replace Thread.sleep with awaitility?

Related

Running tests in a directory parallely in Vitest

I am using Vitest as the testing framework for my project.
I have a directory called canRunInParallel which contains multiple test files, like A.spec.ts, B.spec.ts ..... Z.spec.ts. Since this directory contains multiple test files, and none of the tests can race condition, I want to configure Vitest to run all these tests concurrently, so that I can improve my testing time.
Can anyone help me in figuring out how to achieve the same (by most probably modifying the configuration of Vitest runner)?
This functionality is not yet supported by Vitest.
You can only run the tests in a test suite (test file) concurrently using Vitest.

Is there a way to set up a clean testing environment for Cypress each time I run tests?

We use Cypress for thorough e2e testing on our site.
The Tech stack is React + Node(koa.js).
We have a high test coverage since we tend to mock most of the user actions (most of the crud methods as well).
It happens sometimes that a test suite fails during the execution (or is interrupted by something) so we have a duplicated entry on the next run (create test fails). Then I need to manually delete testing entries from the site and re-run the pipeline.
We want to make sure that we have a clean database for testing on each run. I could use an advice. Thanks in advance!

How to run the same tests with different configuration in jest?

I have a test suite and because it contains some expensive tests, I disable some of them for our CI. However once a day, I'd like to run the whole test suite.
The issue is that running against the same set of test files, it causes snapshot failures because when running the whole test suite it is missing some. If I generate them, then the CI fails because it complains about snapshots being removed (i.e. the one from the whole test suite that are not being checked on the CI.)
What would be the proper way to handle this with jest?
Thanks!

How to use Cobertura maven plugin, so that the bytecode is not altered?

I recently tried to include cobertura plugin for our project. But I ran to a strange problem. Now, if I try to do this:
mvn clean package cobertura:check-integration-test
My project assembles just fine. But after deploy here is what I get as a message:
java.lang.NoClassDefFoundError:
net/sourceforge/cobertura/coveragedata/LightClassmapListener
This happens, as I understand, because cobertura alters the bytecode of my classes. So, how should I proceed with making checks and building the code? Right now I come up with the following solution for teamcity:
First step runs cobertura:
mvn clean package cobertura:check-integration-test
After that second step runs the normal assembly:
mvn clean package
This seems to work, but it seems kind of strange, that I have to run the process of packaging twice (this takes double time), just in order to make a clean build with bytecode unaffected by cobertura plugin.
If you use qualinsight-mojo-cobertura, your classes will backuped at instrumentation time, then restored at reporting time (which will in turn result in having non-instrumented classes in the generated package).
Between intrumentation and reporting you run your tests (be it UTs, ITs) as you want (unlike maven-cobertura-plugin, qualinsight-mojo-cobertura does not run tests). For more information, check the project page (especially the Maven phases the plugin is bound to by default.)

Gallio Integration with NANT and CruiseControl.NET

In our build process we're currently using MBUnit 2.x tests, called from an NAnt task, called from CruiseControl.NET. I've uprgaded to Gallio and MBUnit 3.x locally and am able to run tests from VS2008. I'm having trouble getting our build process upgraded. It looks like we have two options, either run the tests from CruiseControl.net or from NAnt. Based on this, I have two questions:
With all other things being equal, where should these tests be run, NAnt or CruiseControl.net, or does it really matter at all?
If you like doing this sort of thing in NAnt, do you have any documentation or examples of how to implement it? I've found documentation for the CC.NET soution in my Gallio\extra\CCNet directory in the Gallio installation.
Thanks
Your options for running tests as part of your build with Gallio are similar to what they were with MbUnit v2.
I recommend running the tests from your NAnt or MSBuild scripts using the provided tasks in Gallio.NAntTasks.dll and Gallio.MSBuildTasks.dll.
However, if you want to run the tests directly from the CCNet configuration, then you can add a CCNet task to execute the Gallio.Echo.exe program.
Here's a bit more info on the NAnt task that someone else blogged about. Some of the details have changed in recent releases but it should get you on the right track.
http://testdrivendevelopment.wordpress.com/2008/12/01/use-nant-to-run-mbunit-tests-using-gallio/

Resources