When running SBT tests, what is the meaning of the different stats? - junit

When running Scalatest and JUnit tests in SBT I receive a short summary at the end:
Passed: Total 1359, Failed 0, Errors 0, Passed 1358, Skipped 1, Ignored 13, Pending 1
I understand the meaning of the Total count, passed and ignored tests.
But what is the meaning of:
Skipped?. It looks like Ignored but there must be some difference.
Pending?. Aren't all the tests processed when the summary is given?
Difference between Failed and Errors?

Here is an explanation:
Passed means the test has run successfully.
Ignored means the test has been tagged as ignored, probably because it needs to be fixed.
Skipped means the assume condition is not satisfied, and the test is not run. More information
Pending, the test needs to be written. More information.
Difference between failed/error: I'm not sure, but a failed test is a test that has a failed assertion (TestFailedException when using ScalaTest), whereas an error is an unexpected exception.
Total count is the sum of:
Passed
Pending
Failed
Error

Related

Cypress result reports do not show a "passed" status - how to get them to show "pass"?

Most test reporting frameworks show the number of tests run, number passed, number failed and number skipped or ignored. But with the Cypress test reporter options, be it the junit-reporter or the mocha-awesome reporter, they do not show the number passed. Is there a configurable option that would allow the cypress-junit-reporter to show the number of tests that passed?

TestRail: how can I create a separate test plan from tests that failed during some test plan execution?

I have created a test plan consisting of some number of test cases. The QA has executed this plan. The results are in TestRail and I see that some tests were skipped and some tests failed. What I want is to create a special test plan to account for the tests that were not successfull during this particular execution. I dont want successful tests to be included in that plan and I dont want to do it manually.
Is there some routine in TestRail for this?
You could use API from gurock documentation and to do following:
read testRun which is active, read all testcases from it,
from above response catch all failing tests, store it in some collection (List, Map),
read this field "status_id": 2, status should be 2 = failed
create new testRun, and fill it with failed testcases,
You add Your failed testcases in field "case_ids": [1, 2, 3, 4, 7, 8],
Hope this helps,

catching classes that do not inherit from BaseException is not allowed

I'm making a custom plugin to query a database for user info to aide customer support. My backend is slack.
Everytime I start the bot command I'm greeted with:
Computer says nooo. See logs for details:
catching classes that do not inherit from BaseException is not allowed
I'm not sure if this is warning me that I'm attempting to catch an exception that isn't a BaseClass in my code or if an unknown exception was raised and caught elsewhere outside of my plugin.
To debug I tried:
try:
do_the_thing()
except (TypeError, ValueError) as e:
return('Something went wrong.')
I also tried:
try:
do_the_thing()
except Exception as e:
return('Something went wrong.')
And I still get the errbot admonition. Note that the command still runs and does the right thing where there is no exception raised by do_the_thing().
It means that:
Somewhere in your code you have an except ... statement where the exception ... (or one of the exceptions in the sequence ...) is not a subclass of BaseException, and
An exception is being thrown that is caught by that except ... statement.
The TypeError can be raised only when an exception is actually thrown because the names you give to except ... must be evaluated for their current values at that time; just because TypeError referenced a particular class at one point in the program's execution doesn't mean it won't be changed later to reference another object (though that would be admittedly perverse).
The Python interpreter should be giving you a full traceback of the exception; the first thing you need to do is find this. It could be occurring in one of two situations. (This is for single-threaded programs; I'm assuming your program is not multithreaded.)
During the execution of your program, in which case the program will be terminated by the exception, or
During finalization of objects (in their __del__(self) functions) in which case the error will be printed to stderr.
In both cases there should be a stack trace, not just the error message; I've confirmed that at least on Python ≥3.4 a stack trace is printed out for case 2.
You then need to follow this stack trace to see where the problem lies. Remember that the names you give to except ... are variables (even things like TypeError) that can be reassigned, so that you could conceivably be dealing with a (perverse) situation like:
TypeError = False
try:
...
except TypeError:
...
But more likely it will be something obvious such as:
class MyException: # Doesn't inherit from Exception
...
try:
...
except MyException:
...
There is one special case you need to be aware of: if you are seeing messages to stderr (case "2. During finalization," above) printed out as your program exits that means that the exception was thrown during cleanup as the interpreter shuts down, where random variables throughout the program may have already been set to None as part of the cleanup process. But in this case your program should still exit successfully.

Using Assume.assumeTrue or Assert.assertTrue, when do tests exit?

I am using JUnit 4.12 and this is my current understanding of the following APIs I use frequently:
assumeTrue: if expression evaluates to false, test will halt and be
ignored
assertTrue: if condition is false, throws an AssertionError
assertEquals: if they are not equal, an AssertionError is thrown with
the given message
assertNotNull: if it is null, throws an AssertionError
However, I am unable to get clarity on couple of things:
my understanding is that only for assumeTrue, the tests will exit but the very definition of assert is that the program should exit when the statement evaluates to false
when the test throws an AssertionError, does it exit the test case or continue executing the remaining steps?
can the tests be considered pass, even if they throw an AssertionError or are the tests considered fail?
assumeTrue means that the test shouldn't run. It does not mean your code is broken and most runners will treat this test as "ignored"
An AssertionError means the test has failed. No more steps in that test case (the single method) will be run. It would be pointless to do so as the test has already failed
The test has failed. If you want to negate the meaning of a test there are other ways to do that, e.g. replace assertNull with assertNotNull

How to measure number of asserts per line of code in SonarQube

We are attempting to get another view of our code coverage over the standad line and branch-coverage. We would like to get the number of asserts per line/method/class in order to see if we just are running though the code or if we are getting expected results.
So, how to measure the number of asserts in a codebase in sonarcube?
There are a product called pitest that answers to the goal of my question. And there is a plugin for sonar and pitest. So the answer to somehow verify if we actually checks for anything in the tests is: pitest.