minbrowser / min

A fast, minimal browser that protects your privacy
https://minbrowser.org/
Apache License 2.0
7.86k stars 696 forks source link

Unittesting for the code #1275

Open Milad-Laly opened 3 years ago

Milad-Laly commented 3 years ago

I know Unit testing is boring and really annoying. But, I believe if we do unittest the code it will reduce the bugs some users encounter and it's good practice.

https://www.electronjs.org/spectron

https://coveralls.io/ Coveralls will show what lines aren't covered by unit testing and what is covered.

Syndamia commented 3 years ago

I know Unit testing is boring and really annoying.

That isn't the problem here. The problem is that Min is a humongous interconnected web of code. I'm pretty sure making Unit tests will probably be more complicated than the browser itself.

Also, who will write these tests? Right now PalmerAL is practically the only one who knows electron and Min, so he'll be pretty much the only one who can code them, which will slow the development of the browser drastically.

I'm not against the idea, but I think there is a lot that needs to be sorted out before even considering it.

Milad-Laly commented 3 years ago

The thing is the more you put off unitesting the harder it becomes.

I would gladly write unit tests. I have to do it daily for a number of repos and different languages. Electron has easy ways to unittest and it's similar to other languages.

I'm hoping to start coding by 12/10/2020. I just have to finish a couple issues for work.

This wouldn't effect palmerAL main role or anything. I just feel it needs to be done.

Syndamia commented 3 years ago

The thing is the more you put off unitesting the harder it becomes.

Yeah, agree.

I would gladly write unit tests.

Ok then, if you want I can help.

I was just a bit hesitant because right now everything is pushed on PlamerAL's shoulders (and I atleast don't really know electron and such).

Milad-Laly commented 3 years ago

Yeah that be great. unittesting is similar to it all and it might be a bit tricky. But, Electron is practically javascript. If you look at the repos its JavaScript, HTML and CSS. I'm currently working on an issue. I haven't really looked into unittesting too much for this repo. But https://www.electronjs.org/spectron looks decent. But i feel https://mochajs.org/ and https://www.chaijs.com/ should be used as its more flexible and I believe there are more documentation. Electron's own Github repo uses mocha and chai.

I haven't looked into it as much. But yeah I'm trying to fix some of the issues and features PalmerAL has planned to implement so there is less work on him. Electron isn't too different than standard JavaScript. It's just a framework that uses JavaScript for people to access the API's if that makes sense?

PalmerAL commented 3 years ago

I know Unit testing is boring and really annoying

This is basically the reason I haven't done it :)

The problem is that Min is a humongous interconnected web of code.

I think this has kind of gotten better over time as a result of splitting the code into a more modular structure (although there are still a lot of places where it's not). Adding tests is probably going to uncover more places where things should be independent modules but aren't; we could fix those as they come up.

Right now PalmerAL is practically the only one who knows electron and Min

It doesn't have to be that way :) If your goal is to start writing code, I'm open to adding more documentation depending on what you think would be helpful.

There's a document here that has an overview of how Electron's structure works and a bit about how Min is structured: https://github.com/minbrowser/min/wiki/Architecture

I don't know a whole lot about how unit testing works for UI code (which is the majority of what's in the repository) - @Milad-Laly do you have thoughts on that?

Milad-Laly commented 3 years ago

This is basically the reason I haven't done it :) Can't blame you it took me a while to enjoy unittesting.

Adding tests is probably going to uncover more places where things should be independent modules but aren't; we could fix those as they come up.

I agree with this, we can make it more modular to make debugging far easier and adding new features far easier.

@PalmerAL For unit testing on UI code it is possible with https://pptr.dev/ there is a repo that allows it for electron https://github.com/TrevorSundberg/puppeteer-in-electron Also, it is possible just calling it and if it runs successfully without any errors and gets what it expects. The test passes if that makes sense? If it doesn't I can write psuedocode to explain it better.

Syndamia commented 3 years ago

I think this has kind of gotten better over time

By "Min is a humongous interconnected web of code" I meant that Min is just a big app, it has a lot of code and modules and stuff into it, I didn't mean it was messy/unorganized (because it isn't, for a project of such size the current situation is actually really good).

If your goal is to start writing code, I'm open to adding more documentation

You don't need to, my problem is time, when I joined Min I had lots of time (that I mostly used to work on issues) but right now that is the complete opposite. I'll try to help as much as I can and try to learn electron in the snippets of free time I find.

PalmerAL commented 3 years ago

@Milad-Laly That does look like a good option! And I do see how just checking for JS errors would be useful.

@Syndamia I definitely understand the time issue; I don't have a whole lot of time at the moment either. But if you ever have any questions (about Min or Electron in general), do let me know.