What is sequence coverage? - ruby

I am using simplecov for code coverage. I have no idea what sequence coverage is. I Googled it but I could not find anything, although I did find information about Branch Coverage.
Here is what I see in Shippable CI:

The term "Sequence coverage" comes from Shippable CI, not simplecov.
From Shippable's API documentation we can find this:
branchCoveragePercent The percentage of branches (if/then/else condtions) that are covered by tests
sequenceCoveragePercent Percentage of lines there are code coverage for
So branch coverage counts all your code branching such as:
if a==b
do stuff # branch 1
else
do other stuff # branch 2
end
Now if your test suite only tests when a==b, your branch coverage for this file is 50%.
Sequence coverage is the regular line by line coverage report, if your code has 100 lines and during the tests only 70% of the lines have been run, your sequence coverage is 70%.

Evidently "Sequence Coverage" is a Shippable CI term. According to Shippable CI's docs, "sequence coverage" just means line coverage. Perhaps they chose that term to contrast to "branch coverage".

Related

TeamCity - GitVersion generates the build number unexpected

I have the git commits and the tags as below
The tag of the latest commit is 12.0.0-beta.6. When I run GitVersion, the result is as below
So the build number on TeamCity should be 12.0.0-beta.6, but I don't know why the GitVersion generates build number 12.0.0-beta.6+8 on TeamCity.
My build steps are as below
Does anyone know why GitVersion generates the redundant "+8" after the FullSemVer?
How to remove this dedundant "+8"?
Thank you very much.
The +8 is metadata and not actually part of the version number. In the documentation for the version variables, BuildMetaData is described as:
The build metadata, usually representing number of commits since the VersionSourceSha.
You can see the same value 8 exposed as CommitsSinceVersionSouce and this should increase with every commit made to the branch since its "version source", which in this case is the tag 12.0.0-beta.6 made on commit 549a1d.
The metadata does not increase with every build, but with every commit. I can see how the current language is confusing and the name BuildMetaData does not help. Since BuildMetaData is an exposed variable, we can't change its name, but I've submitted a PR that will hopefully clarify its documentation.
Read carefully and understand at least part of GitVerson docs (paragraphs 1+2)
The shortest possible extraction
GitVersion will increment the metadata for each build so you can tell
builds apart. For example, 1.0.0+5 followed by 1.0.0+6. It is important
to note that build metadata is not part of the semantic version; it is
just metadata!

SonarQube does not create graphs on project dashboards

SonarQube Metrics graphs are not being displayed on my project dashboards behind the total numbers and Quality Gate ratings.
Current versions of SonarQube and plugins and MySQL 5.7. I am creating a new SQ project through its Administration->Projects->Management->Create Project and then performing analyses as follows (anything capitalized is either a variable or anonymized): *
MSBuild.SonarQube.Runner.exe begin /k:KEY /v:VERSION /d:sonar.host.url=http://localhost:9000/ /d:sonar.login=TOKEN /d:sonar.projectDate=YYYY-MM-DDTHH:MM:SS+0000
MSBuild.exe /maxcpucount /nr:false /nologo /target:rebuild /verbosity:quiet PROJECT\PROJECT.sln
MSBuild.SonarQube.Runner.exe end /d:sonar.login=TOKEN
I have tried VERSION equal to a constant value "1.0" and VERSION equal to a string of the UNIX time (seconds since 1/1/1970) of each git commit I analyze. I've also tried configuring project leak periods of the last 90 days and also previous_analysis, though I think that would only affect the graphs in the right column. If someone could tell me what I am doing incorrectly, I would appreciate it.
* These are examples of the commands executed by a Python script that is iterating over a list of git commit hashes and their associated timestamps, in increasing order, to populate the project history. The python script in turn is mimicking a Jenkins job that will eventually take over calling SonarQube.
Background Tasks page:
Your project homepage screenshot shows the graph in the leak period, but not extending left into the Overall section.
This is going to be a question of your analysis date and your definition of "leak period". If your leak period is set to previous_version, then you need to take a look at the sonar.version values in your analyses. So far, it looks like all your analyses are leak period analyses, which is why nothing has filtered left into the overall view.

Understanding SonarQube C code coverage measures

I have a SonarQube 5.6 installation, using C/C++ plugin 3.12 to analyse our project. I have generated coverage results (gcov), but so far only for one of the application C files. The coverage is at 98.3%.
When analysing the whole project that application coverage results gets 'imported' and I can trace them on the web interface.
On the top-level Code page the folder containing that file shows then 98.3%, which in my view is not correct, since for all the other C files no coverage is yet available. I've tried to show that in the following series of snapshots:
(1) Top-level Code Tree:
(2) Going down the 'Implementation' tree:
(3) Going down the 'Implementation/ComponentTemplate' tree:
(4) Going down the 'Implementation/ComponentTemplate/code' tree:
EXMPL.c has only (4):113 Lines of Code. Compared to the total Lines of Code of 'Implementation' (4):61k, this is somewhere of about 0.2% only.
The coverage for EXMPL.c of 98.3% in (1) is then wrong !
My project consists of several applications, EXMPL is one - the smallest one - of all my applications within the project. So I have to produce separate coverage results for each application and to 'import' them seperately into sonar. Coverage result files are therefore located in different folders.
Maybe that project structure or the 'incomplete import' of coverage results is the cause of the 'wrong' coverage measures, but so far, I have not found any useful information on how sonar is handling provided gcov coverage measures.
Any help or information will be appriciated.
Thanks
Your second guess is right: the incomplete import of coverage results is what's skewing the numbers. Lines that aren't included in the coverage report aren't included in the coverage calculations. Since the current coverage report includes only one file that's 93% covered, all the numbers are based on that.

Emma not recording line coverage even though it executed

Am using emma for recording code coverage. Am particularly interested in the line coverage (or line %) We are planning to increase the line coverage for our source code thru' automation. We first execute the scenarios manually and then check using emma if there is an increase in line%. If there is, we go ahead and automate that feature. Am stuck with a particular IF-ELSE block where i see the desired result when i manually run the scenario. But emma is not recording the line as covered. Here's the sample code below
if (a == null)
{
final class1 c1 = new class1();
if (c1.isSE())
{
c1.sendRedirect(req, res, "error.html");
}
else
{
c1.sendRedirect(req, res, "testpage.html");
}
return;
}
First 3 lines are green in emma report. But, the following lines below are in red in the emma report (meaning they are not covered)
c1.sendRedirect(req, res, "error.html");
c1.sendRedirect(req, res, "testpage.html");
return;
But when i execute the scenario manually, am seeing the desired result (i.e. am redirected to testpage.html page) Why is emma not recording this line as covered?
Note: I have tried the following troubleshooting below (mentioned in http://emma.sourceforge.net/faq.html )
3.18. EMMA started reporting that it instrumented 0 classes even though I gave it some input...
You might be getting tripped up by the incremental nature of EMMA instrumentation. When debugging an EMMA-enabled build, try either a
clean recompile and/or delete all instrumentation output directories
and all .em/.ec files by hand to reset EMMA to a clean state.
May be useful for the future people who refer to this...
When you instrument the Jars.you can see emma listing some of the classes with "Class Compiled without Debug Mode". If you see these messages when instrumenting then the Line % Coverage will not be generated. To overcome this you either need to compile those classes in debug mode or consider excluding if those classes are not required. Usually the classes with the above mentioned message will be third party classes.
If you don't see the Message "Class Compiled without Debug Mode" while instrumenting - then you should see the Line coverage in your report.

Is there a good way to debug order dependent test failures in RSpec (RSpec2)?

Too often people write tests that don't clean up after themselves when they mess with state. Often this doesn't matter since objects tend to be torn down and recreated for most tests, but there are some unfortunate cases where there's global state on objects that persist for the entire test run, and when you run tests, that depend on and modify that global state, in a certain order, they fail.
These tests and possibly implementations obviously need to be fixed, but it's a pain to try to figure out what's causing the failure when the tests that affect each other may not be the only things in the full test suite. It's especially difficult when it's not initially clear that the failures are order dependent, and may fail intermittently or on one machine but not another. For example:
rspec test1_spec.rb test2_spec.rb # failures in test2
rspec test2_spec.rb test1_spec.rb # no failures
In RSpec 1 there were some options (--reverse, --loadby) for ordering test runs, but those have disappeared in RSpec 2 and were only minimally helpful in debugging these issues anyway.
I'm not sure of the ordering that either RSpec 1 or RSpec 2 use by default, but one custom designed test suite I used in the past randomly ordered the tests on every run so that these failures came to light more quickly. In the test output the seed that was used to determine ordering was printed with the results so that it was easy to reproduce the failures even if you had to do some work to narrow down the individual tests in the suite that were causing them. There were then options that allowed you to start and stop at any given test file in the order, which allowed you to easily do a binary search to find the problem tests.
I have not found any such utilities in RSpec, so I'm asking here: What are some good ways people have found to debug these types of order dependent test failures?
There is now a --bisect flag that will find the minimum set of tests to run to reproduce the failure. Try:
$ rspec --bisect=verbose
It might also be useful to use the --fail-fast flag with it.
I wouldn't say I have a good answer, and I'd love to here some better solutions than mine. That said...
The only real technique I have for debugging these issues is adding a global (via spec_helper) hook for printing some aspect of database state (my usual culprit) before and after each test (conditioned to check if I care or not). A recent example was adding something like this to my spec_helper.rb.
Spec::Runner.configure do |config|
config.before(:each) do
$label_count = Label.count
end
config.after(:each) do
label_diff = Label.count - $label_count
$label_count = Label.count
puts "#{self.class.description} #{description} altered label count by #{label_diff}" if label_diff != 0
end
end
We have a single test in our Continuous Integration setup that globs the spec/ directory of a Rails app and runs each of them against each other.
Takes a lot of time but we found 5 or 6 dependencies that way.
Here is some quick dirty script I wrote to debug order-dependent failure - https://gist.github.com/biomancer/ddf59bd841dbf0c448f7
It consists of 2 parts.
First one is intended to run rspec suit multiple times with different seed and dump results to rspec_[ok|fail]_[seed].txt files in current directory to gather stats.
The second part is iterating through all these files, extracts test group names and analyzes their position to the affected test to make assumptions about dependencies and forms some 'risk' groups - safe, unsafe, etc. The script output explains other details and group meanings.
This script will work correctly only for simple dependencies and only if the affected test is failing for some seeds and passes for another ones, but I think it's still better than nothing.
In my case it was complex dependency when effect could be cancelled by another test but this script helped me to get directions after running its analyze part multiple times on different sets of dumps, specifically only on the failed ones (I just moved 'ok' dumps out of current directory).
Found my own question 4 years later, and now rspec has a --order flag that lets you set random order, and if you get order dependent failures reproduce the order with --seed 123 where the seed is printed out on every spec run.
https://www.relishapp.com/rspec/rspec-core/v/2-13/docs/command-line/order-new-in-rspec-core-2-8
Its most likely some state persisting between tests so make sure your database and any other data stores (include class var's and globals) are reset after every test. The database_cleaner gem might help.
Rspec Search and Destroy
is meant to help with this problem.
https://github.com/shepmaster/rspec-search-and-destroy

Resources