-2

I have a CSS file on a webpage. I have a bunch of selenium tests that validates the styles for a component. I want to instrument this CSS file to generate the code coverage for it? Is this possible?

Any help on this is highly appreciative.

Eajaz
  • 469
  • 4
  • 21

2 Answers2

1

Why do you want to generate code coverage for CSS? This seems rather odd as you cannot be sure that the CSS written will be displayed in the browser due to specificity etc.

You can use the Galen test framework to test the styling of UI components: http://galenframework.com/

itodd
  • 2,278
  • 1
  • 14
  • 14
0

"Instrumenting" a CSS file, no, that doesn't really make sense since CSS stylesheets do not contain executable code in the way that Java or JavaScript source/class files do.

What you can do to detect unused styles, rules, etc., is to use a static analysis tool that understands CSS. Certain Java IDEs (IntelliJ IDEA, at least) do have this ability. There are also dedicated tools for CSS analysis and optimization as well, as mentioned in this other answer.

Rogério
  • 16,171
  • 2
  • 50
  • 63