Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code coverage tools for haml?

It looks like it's quite possible to get a useful coverage report for Haml code, due to its one one-statement-per-line structure.

Do you know of any code coverage tools for Haml? Maybe something is in the works?

like image 371
Leonid Shevtsov Avatar asked Mar 02 '11 11:03

Leonid Shevtsov


People also ask

Which tool is used for code coverage?

Cobertura. Cobertura is an open-source tool for measuring code coverage. It does so by instrumenting the byte code.

What is the best updated code coverage tool?

#1) Parasoft JTest Its report provides a good picture of code covered and thereby minimizes risks. Key Features: It is used for Java-based applications. It is a multi-tasking tool which includes Data flow analysis, Unit testing, Static analysis, runtime error detection, code coverage testing etc.

How do I find my code coverage?

To calculate the code coverage percentage, simply use the following formula: Code Coverage Percentage = (Number of lines of code executed by a testing algorithm/Total number of lines of code in a system component) * 100.

How do I check code coverage in Ruby?

With RubyMine, you can measure how much of your code is covered with tests using the SimpleCov analysis tool. You can run tests with coverage for any supported testing framework, analyze the percentage of covered files and lines in a separate tool window and editor, generate HTML reports, and so on.


2 Answers

Code coverage generally makes sure you cover all your code-paths. If you have a lot of logic in your view, that is a smell. I think logic should be moved to your helpers, controllers (render a different view) or presenters, and those you can test with perfect coverage.

Aside of that: theoretically it should be possible, but i would not want to encourage placing too much "intelligence" in views.

like image 85
nathanvda Avatar answered Oct 08 '22 11:10

nathanvda


One problem with non-mainstream languages (such as HAML) is that tools are hard to find, because they are hard to build.

This technical paper Branch Coverage for Arbitrary Languages Made Easy (I'm the author) describes how to build test coverage tools for langauges in systematic way to help get around this problem, using a generic tool-building infrastructure.

like image 29
Ira Baxter Avatar answered Oct 08 '22 11:10

Ira Baxter