How to measure the code coverage of your tests

David Chavez
Giga Contributor

Hi,

I'm using the ATF to test my application but I wonder if there is a way to know how much code it's been tested.

I've found a plugin called js code coverage debug but it is not usefull for this purpose casuse it doesn't return a neat value of your code coverage.

Do you know if there is any solution out there? What do you do to handle your code coverage?

Thanks!

4 REPLIES 4

mohammedsikande
Tera Contributor

Hi David,

Did you get any lead on this? Could you please share, thank you in advance.

Thanks and regards,
MSS

Chirag Shah1
Tera Contributor

Hi David,

Just curious if you found a solution to this? 

Thanks

kulbhusanazad
Tera Contributor

i am too interested if anyone found any solution regarding this

Ramesh Lohar
Kilo Guru

ServiceNow does not have a built-in feature to measure code coverage directly. However, there are some strategies you can use to estimate your code coverage:

1. **Automated Test Framework (ATF)**: ATF is a ServiceNow tool that allows you to create and run automated tests on your ServiceNow applications. It can help you ensure that your code works as expected after changes. Although it doesn't provide a direct measure of code coverage, you can use it to test your code thoroughly.

2. **Unit Testing**: You can write unit tests for your scripts to ensure they work as expected. This can give you a good idea of how much of your code is covered by tests.

3. **Code Review**: Regular code reviews can help ensure that your code is thoroughly tested. During a code review, you can check to see if there are any parts of the code that are not covered by tests.

4. **External Tools**: There are external tools available that can measure code coverage for JavaScript, which is the language used in ServiceNow scripts. Tools like Istanbul or JSCoverage can be used to measure code coverage, but integrating them with ServiceNow may require some work.

5. **Manual Testing**: Manual testing is another way to ensure your code is working as expected. Although it's more time-consuming than automated testing, it can be a good way to check for issues that automated tests might miss.

Remember, the goal of testing is not just to achieve a high code coverage percentage, but to ensure that your application works as expected and is free of bugs.


nowKB.com