Skip to content

Commit 678d615

Browse files
authored
Merge pull request #5439 from satyasaibhushan/add_wrapup
2 parents 817b280 + 9f038dd commit 678d615

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

contributor_docs/project_wrapups/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This folder contains wrapup reports for projects from p5.js related [Google Summ
1111
* [Internationalization(i18n) and Deployment of p5.js website](https://github.com/processing/p5.js/blob/main/contributor_docs/project_wrapups/sanjay_singh_rajpoot_gsoc2020.md) by Sanjay Singh Rajpoot, 2021
1212
* [Improving the p5.xr Library Through Artistic Examples](https://github.com/processing/p5.js/blob/main/contributor_docs/project_wrapups/anaisgonzalez_gsoc_2021.md) by Anais Gonzalez, 2021
1313
* [Korean Translations and Website Redesign Proposal](https://github.com/processing/p5.js/blob/main/contributor_docs/project_wrapups/josephhong_gsoc_2021.md) by [Joseph Hong](github.com/jhongover9000), 2021
14+
* [Improve Test Coverage in p5.Sound library](https://github.com/processing/p5.js/blob/main/contributor_docs/project_wrapups/sai_bhushan_gsoc_2021.md) by [Sai Bhushan](https://github.com/satyasaibhushan), 2021
1415

1516
### Google Summer of Code 2020
1617
* [p5.js accessibility and canvas descriptions](https://github.com/processing/p5.js/blob/main/contributor_docs/project_wrapups/luismn_gsoc_2020.md) by Luis Morales-Navarro, 2020
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<p align="center">
2+
<img src="https://github.com/satyasaibhushan/gsoc-21-wrapup/blob/master/assets/gsoc.png" alt="gsoc logo" width="300" style="margin-left:50%;transform:translateX(-50%);"/>
3+
</p>
4+
5+
<p>
6+
7+
# Project Overview
8+
This project aimed at -
9+
10+
Improving Test Coverage of p5.js sound library which includes
11+
12+
* correcting the current tests
13+
* Writing new tests
14+
* Improving the testing architecture and implementing headless-tesing to the library
15+
* Adding documentation to the library regarding testing.
16+
17+
</p>
18+
19+
## 1. Improving Current tests
20+
At the beginning of the project, some of the tests written in the library seem to be broken(like 20 %). Some of these are due to the problems in code which went by unnoticed as testing is not frequently performed to the library. Some of these are due to the tests for which most of them were solved by using `setTimeout function`.
21+
22+
[Week-1 's PR](https://github.com/processing/p5.js-sound/pull/626)
23+
At the end of week-1, I've fixed all the failing tests except one. Which I came back to in week-2.
24+
I've fixed some bugs in week-2 that caused that one test to fail and also corrected an example related to that issue.
25+
26+
[Week-2 issue](https://github.com/processing/p5.js-sound/issues/627)
27+
[Week-2 PR](https://github.com/processing/p5.js-sound/pull/628)
28+
29+
## 2. Writing new tests
30+
Most of my time during this period is spent on writing new tests to the library and improving it's testing range.
31+
In weeks-3,4 I've added tests to the files which are not yet covered(16 files). At this week, I've decided on the style/suite design of the library's tests, which I followed for the rest of the project's period with some minor changes
32+
33+
[Week-3,4 PR](https://github.com/processing/p5.js-sound/pull/632)
34+
At this point, all the files of the library were covered.
35+
36+
In weeks-6,7 I've added tests to files which are already coverd(15 files). This is a larger work than week-3,4's as some of the files were massive and needed like 1000 lines of code to test the entire file. During these weeks(3-7), I also fixed some bugs which I came across this period. Later I raised a PR regarding these bugs.
37+
38+
[Week-6-7 PR](https://github.com/processing/p5.js-sound/pull/636)
39+
[Bug fixing PR](https://github.com/processing/p5.js-sound/pull/639)
40+
41+
## 3.Headless testing
42+
I spent the last 3 weeks or so on implementing headless testing. During this period, I did some minor changes in testing architecture.
43+
I also implemented headless testing of mocha by using puppeteer, which is inspired by p5.js's testing.
44+
### Problems faced:
45+
* I took some time figuring out the testing of mic in headless mode and figured out that it can be solved by mocking the microphone to use the buffer from a sound file
46+
* I also fumbled upon the problem that some user interaction is required to start some audio nodes and later figured out that it can be solved by adding a flag while initialising puppeteer.
47+
* After implementing the headless testing using puppeteer, I figured out that testing in that way is not consistent for this library. Some audio nodes are not being properly initialised and the tests were failing. So, I've implemented Karma to solve this problem.
48+
* As the tests in karma were also not consistent, I used karma-webpack to bundle the test files, which seemed more consistent.
49+
* As I found out even then some tests were failing, I implemented mocha's retry functionality to some test cases.
50+
51+
52+
At the start of the project, I thought of implementing the headless testing and using it in github automations, but did not do it as even after implementing all these, some tests were failing in karma-js. Not always, but very rarely. As we cannot take risks on github automations, I refrained from implementing it.
53+
54+
Also, at the time of writing this document, the last PR is not yet merged. But will hopefully merged whithin a couple of days.
55+
[Week-8,9,10 PR](https://github.com/processing/p5.js-sound/pull/641)
56+
57+
## 4.Documenting
58+
During the last week of my project, I used my time to merge the work done and write a wiki page about the current testing architecture and on how to write tests, focused on beginners. The wiki can be found in library's wiki page.
59+
60+
61+
# Future of p5.js-sound's testing
62+
I've done almost every thing I thought of doing at the beginning of the project. But, there were some things that can be improved/implemented in the future:
63+
* We should figure out a way to visualise to the coverage of test files.
64+
* Some failing tests need to be corrected and the github automations needs to be implemented.
65+
* If any file/functionality is added in the future, tests for those should be added.
66+
* After the coverage is implemented, we should write test cases for files which are poorly covered.
67+
68+
# Acknowledgements:
69+
During this period of 10 weeks, I've done a lot of work and learnt a lot in my way.
70+
As you can see below, the before and after images, I've implemented more than 300 test cases and increased the test coverage 5 folds.
71+
72+
### before :
73+
<p align="center">
74+
<img src="https://github.com/satyasaibhushan/gsoc-21-wrapup/blob/master/assets/before.png" alt="a picture showing the result of running testcases before the project" width="300" style="margin-left:50%;transform:translateX(-50%);"/>
75+
</p>
76+
77+
### after :
78+
<p align="center">
79+
<img src="https://github.com/satyasaibhushan/gsoc-21-wrapup/blob/master/assets/after.png" alt="a picture showing the result of running testcases after the project" width="300" style="margin-left:50%;transform:translateX(-50%);"/>
80+
</p>
81+
82+
83+
84+
85+
I am extremely grateful to the community and Gsoc. I sincerely appreciate my mentor [Guillermo](https://github.com/guillemontecinos) for his constant support and motivation provided throughout the period. I had a great time!!

0 commit comments

Comments
 (0)