Posts: 9
Joined: Jun 2017
Reputation:
0
Hello,
I have a Addon Source hosted on github an want to use a continous integration to test if PRs are working or not. Is there a way to do this or do I need to test every PR manually before merging it?
Posts: 1,663
Joined: Jun 2011
Reputation:
119
Addons are no different than any other Python programs so nothing prevents you from using unit/integration tests in a CI environment. Obviously, you will need to mock Kodi Python API calls.
Posts: 9
Joined: Jun 2017
Reputation:
0
Is there a mock for the API where I can start from or do I need to start there from scratch?
Posts: 1,663
Joined: Jun 2011
Reputation:
119
However, you need to understand that such tests that rely heavily on mocking some external API that is out of your control are not very reliable by themselves. They are only as good as your mocks and you may end up testing your mocks and not your primary code. So in my opinion in case of Kodi addons unit tests are good only for catching basic things such as syntax errors and typos, and not for any serious functional testing.
Posts: 9
Joined: Jun 2017
Reputation:
0
The problem is I think that for good testing kodi needs a way to start itself from cli and do the unit tests inside of kodi...
Posts: 12,706
Joined: Nov 2003
Reputation:
129
spiff
Team-Kodi Member
Posts: 12,706
which is the why of the discussion about mocking.
Posts: 9
Joined: Jun 2017
Reputation:
0
No if kodi natively can run unittests it isn't needed to mock anything...
Posts: 12,706
Joined: Nov 2003
Reputation:
129
spiff
Team-Kodi Member
Posts: 12,706
you can't fire up kodi, a media center, on a CI node. you have to mock.
Posts: 9
Joined: Jun 2017
Reputation:
0
You could do this but kodi isn't made for because there is no cli
Posts: 12,706
Joined: Nov 2003
Reputation:
129
spiff
Team-Kodi Member
Posts: 12,706
fine, if you want to argue like that, yes, if somebody rewrote shitloads of code in kodi, then you could do it.
Posts: 9
Joined: Jun 2017
Reputation:
0
That's the problem with the plugin desgin, I can't test them...
So I end up testing my mocking or I could manually test all PRs...
Posts: 1
Joined: Nov 2018
Reputation:
0
Total Kodi newbie here, and I was wondering the same thing. To keep the topic alive and on a constructive note, I think there should be a separation (as much as possible) of an actual functional add-on code and the code that uses C modules imported from the Kodi binary, perhaps in form of an adapter. Then writing testable code should become much more manageable. Does anybody know whether any existing add-on already employs such design?