axios interceptor code is not covered in jest - axios

When running jest test having Axios interceptor mocks the code is not covered for interceptor
The Axios code:
jest tests
The code coverage
I want 100% code coverage but interceptor code is not covered here

Related

Dart testing: how to run code to prepare all the suite of tests

I want to run some code before ALL the test suite runs, like loading i18n files or preparing some models for all the suite.
Is there any main or beforeAllSuite that we could use for that?

Mockito not generating mocks

I had some existing mocks with mockito. I changed the names of some classes that had been mocked and now mockito doesn't generate mocks for them anymore.
An example is:
import 'package:mockito/annotations.dart';
import 'package:vepo/src/presentation/pages/manage_vegan_items/page/helpers/manage_vegan_items_page_vm.dart';
#GenerateMocks([ManageVgnItmsPageVm])
void main() {}
It is imported without error. After running flutter pub run build_runner build, no mocks have been generated for the newly named classes. The app runs fine. Does anyone know what might have caused mockito not to generate the mock files?
It worked when I moved the mock in the question to the test/ directory

Visual Studio Code: How to check unit tests coverage for Python unittests?

I have unit tests written in Python's unittest library but I'm not sure how to check unit test coverage. I'm using VS Code version 1.68.1.

How to run JUnit5 tests in SAP Commerce 1808

Currently we are using JUnit4 testing framework in our project with SAP Commerce 1808, and the unit tests are working fine.
However, we would like to start using JUnit5 framework. After importing respective JUnit5 libraries and compiling the unit test, I have run the command in the console:
ant unittests -Dtestclasses.packages=<package_name> -Dtestclasses.suppress.junit.tenant=true
ant was not able to find the test class and showed the output in the console:
...
[echo] No tests found!
Which is surprising, because I have used the annotation #UnitTest before the class name:
#UnitTest
public class ClassName{
...
}
Trying to find an answer, I searched for examples of unit tests in SAP Commerce documentation: https://help.sap.com/viewer/d0224eca81e249cb821f2cdf45a82ace/1808/en-US/aae25ecb74ab4bd69cc5270ffd455459.html and noticed that all the unit test examples use only JUnit4 framework.
Also I checked Hybris out-of-the-box code and also saw that only JUnit4 framework is used there.
So the question is: how to run JUnit5 tests in SAP Commerce 1808?

Use custom scalatest html report that will include not only assertion error, but also additional log information

Currently, in our company, we are using scalatest to write integration API tests for our backend. We run our tests in IntelliJ IDEA and there we can export test result into HTML format. What nice about this report is that includes information about latest API calls that were made before assertion fail happened. That's very handy. However, when we try to run our tests in Jenkins, then we get scalatest HTML report that only has information about a number of failed/passed tests and that's it. In Jenkins job, we use JUnit test report plugin, which show's us failed tests with an assertion error, but this report doesn't contain log information about latest calls that were made. Allure report are not ready to work with Scala 2.11 yet and i haven't found any easy way to extend or modify scalatest in order to add more information into error message. The only way i see for now is to use scalatest withClue method, but that doesn't seem very nice solution for me. I want to see request and response details of the last executed API call.
In build.sbt file we are using next options for running and publishing our test results:
// Parallel testing configuration
parallelExecution in Test := false
testOptions in Test ++= Seq(
Tests.Argument(TestFrameworks.ScalaTest, "-u", "target/test-reports-xml"),
Tests.Argument(TestFrameworks.ScalaTest, "-h", "target/test-reports-html"),
Tests.Argument(TestFrameworks.ScalaTest, "-oDWF"),
Tests.Filter(s => s.endsWith("TestSuite"))
)