Name: Univer
URL: https://github.com/dream-num/univer
Number of lines of code and the tool used to count it: 226237 counted through Lizard
Programming language: Typescript
The project is compiled with vite , and the test tool vitest is able to generate a local coverage report. By executing pnpm run coverage, the package.json calls Turbo, which calls vitest run --coverage for each package. Turbo is the management tool to compile the different packages of this repository into a single product.
As this repository is a mono repository, each package generates their own report. To get a global report, we have implemented a script called merge-coverage.cjs. This script copies all the local coverage-final.json into a coverage/.nyc_output folder, as {package}-coverage.json. Finally it calls nyc report --reporter=html --reporter=text-summary. This generates the same report as each vitest run --coverage, but as it contains all the coverage overviews, it will generate the report for the global coverage.
https://github.com/JariRoossien/univer/commit/ef90d965ead24dd295f9bea6e39dbd83ec3ed538
https://github.com/JariRoossien/univer/commit/50c0accdc9a46b093bb0114481c3325fc2f9cfb7
Link to commit: https://github.com/dream-num/univer/commit/e402af0b9c40e783b7c13e0542fe1cd0f4bfd2f4
Coverage tool results:
Out of the 15 branches, only 3 were hit with unchanged tests, meaning the coverage for this function is at 20%.
Link to commit: https://github.com/dream-num/univer/commit/e3401afbd670d59a3f5052254282f1fcfe9a0ce1
Coverage tool results:
With the current tests, none of the 6 branches were hit, resulting in 0% coverage.
Link to commit: https://github.com/JariRoossien/univer/commit/ddc266f6ca82e8f459bccd3341feba3e633b1dc8
3 out of 7 were hit, meaning a branch coverage of 43%
Link to commit: https://github.com/JariRoossien/univer/commit/df9614ae2ee8b45cd76ff3b324276241f8b918bc
Coverage tool results:
None of the 8 branches were hit, giving a 0% coverage.
The branch coverage has been improved from 0 branches covered, to 7 out of 8 branches covered (87.5%). As there weren't any tests, most edge cases have been found. This contains different cases such as the unitID of the sheet not existing, the SheetID not existing, or the SId not existing. As the test suite created a mock object for a different test case, I modified the values to check for true and false based on the data as described in the mock sheet. The tests themselves check for all the possible nullified values and makes sure the function catches them.
For coverage has been improved from 0 branches covered, to 9 out of 11 branches covered (81.8%). This function was originally tested using the given formulaDataModelArray that was mocked by the test suite. For each run, a different input was mocked, starting from completely nullified values, to completely correct, and partially missing data. As the test worked with a formula range that was given by a different function, some tests mocked that given data before the function itself was called, to make sure in different situation the code would behave as expected.
The code coverage has been improved from 0% (0/11 branches) to 81.82% (9/11 branches). The coverage has been improved by considering many edge cases and ensuring all cases in which a program can fail are tested. For this some test cases had to be specifically constructed since the test case should only fail if another part of the program malfunctions or is changed. To emulate this, flawed inputs where constructed artificially and the brach coverage was achieved by the program catching those exceptions and handling them appropriately.
The code coverage has been improved from 0% (0/9 branches) to 100% (9/9 branches). The function is intended to replace NaN values in a range with the extremes (0 or max - 1). For this purpose the tests supply a NaN value in ecah of the possible positions. The branch coverage is then achieved by the program handling all NaN values and replacing them with the correct default values.
Link to commit: https://github.com/dream-num/univer/commit/95055e3b2f22a5597a4ab7f22d16ea747d545a40
The coverage improvement is 80%, since the coverage started out at 20% and is now 100%. The way this was done was by creating tests that hit every branch.Link to commit: https://github.com/dream-num/univer/commit/b6afab73e679a01dc610f3fe051e68e742c9aaa1
The coverage improved by 83.3%, since in the beginning 0 branches were covered by the tests and after the improvements were made, 5 out of the 6 branches were hit. This was also done by writing tests that hit the branches.
Link to commit: https://github.com/JariRoossien/univer/commit/ec699062f8eb8187fed36378ee35ae8c37614e35 https://github.com/JariRoossien/univer/commit/5fa144f88ba37f4bd0da536ccfd4e60f1bab0619
Coverage before improvement:
Coverage after improvement:
Coverage has been improved from 3/7 (42%) to 7/7 (100%). The original test only checked for a correct statement when the content was bold. I have implemented tests where these were not completely covered, where the effect is disabled, or where different effects have been used.
Link to commit: https://github.com/JariRoossien/univer/commit/7870a34be59283120b4532d488c9e1b577bf2a14
Coverage before improvement:
Coverage after improvement:
Coverage has improved from 0 branches hit, to all 8 branches hit, giving a 100% coverage. The coverage has been improved by creating test cases for multiple possiblities. Ranging from just having valid inputs, to leaving certain values at NaN or empty to trigger the if statement clauses.
Improvements made:
- +0.27% statement coverage
- +0.31% branch coverage
- +0.15% function coverage
- +0.27% line coverage
Set up github repository, implemented custom script to combine existing tooling for code coverage, implemented tests and coverage tooling for getFormulaItemBySId and clearPreviousArrayFormulaCellData.
Implemented tests and coverage tool for SetWorksheetShowCommand and setEndForRange
Implemented tests and coverage tooling for extractFilterValueFromCell function and InsertRowAfterCommand command.
Added tests and coverage tool for isValidRange and isAllFormatInTextRuns