Joomla and the unittests

89 views
Skip to first unread message

Hannes Papenberg

unread,
Nov 8, 2016, 8:41:44 PM11/8/16
to Joomla! CMS Development
Hi folks,
I've been working on improving and cleaning JForm for Joomla 4.0
(https://github.com/joomla/joomla-cms/pull/12414) and also worked hard
on cleaning up the unittests. It took me several days of continous work
to properly test JForm and get a 100% code coverage. I just achieved
that 10 minutes ago and then went to work on JFormField to get those
unittests improved.

I'm taking JFormField as an example here, other areas are equally
horrible. That class has next to no proper unittests! Ok, I can live
with that, lots of code has been already in the project before we
started writing unittests somewhere at the end of the 1.6 development.
But for fucks sake: Why are you still accepting completely new methods
with large new features without any tests? We had a rule in the past
that no new code gets added to the libraries folder without proper
testcoverage.

I can turn a blind eye for the occasional changed or added line of code
to fix a bug or something, which might show up in the code coverage
report, but not large new features that are being added like in
JFormField just 10 days ago. If that rule is not being enforced, I
wonder why I invest weeks and months of work into writing good tests for
my PRs. I currently feel like I'm not only wasting my time with writing
those tests, I'm also creating more issues with that for me, since I
have to not only fix issues that people report when testing, but also
explain why the tests don't work with my code-change. >:-(

Hannes

Bakual

unread,
Nov 9, 2016, 3:48:48 AM11/9/16
to Joomla! CMS Development
Because the average developer (myself included) doesn't really know how to write unit tests. And before you say "Then learn it" remember we're all volunteers here.

Main question is: Do we want to reject a new great feature just because the developer didn't know (or haven't had the time) to write unit tests?

Don't get me wrong. I think unit tests are important. But we would need some people working on them and especially helping other developers with creating them.

Chris Davenport

unread,
Nov 9, 2016, 4:00:25 AM11/9/16
to Joomla! CMS Development
Hannes, please mind your language.  Thank you.

Chris.

Hannes Papenberg

unread,
Nov 9, 2016, 4:08:13 AM11/9/16
to joomla-...@googlegroups.com
I expected such an answer. That still makes me angry that I'm wasting my
time on creating unittests for all of my PRs. Considering all the time
that I spent writing unittests for those damn routing changes and I
could have just sent them in without all of this and simply let you guys
test until your fingers bleeded...

Ok, enough whining. I will create the necessary tests for JFormField for
the code that I wrote and mark the rest as incomplete. Then that is not
my problem anymore.

Hannes

Am 09.11.2016 um 09:48 schrieb Bakual:
> Because the average developer (myself included) doesn't really know how
> to write unit tests. And before you say "Then learn it" remember we're
> all volunteers here.
>
> Main question is: Do we want to reject a new great feature just because
> the developer didn't know (or haven't had the time) to write unit tests?
>
> Don't get me wrong. I think unit tests are important. But we would need
> some people working on them and especially helping other developers with
> creating them.
>
> Am Mittwoch, 9. November 2016 02:41:44 UTC+1 schrieb Hannes Papenberg:
>
> Hi folks,
> I've been working on improving and cleaning JForm for Joomla 4.0
> (https://github.com/joomla/joomla-cms/pull/12414
> <https://github.com/joomla/joomla-cms/pull/12414>) and also worked hard
> on cleaning up the unittests. It took me several days of continous work
> to properly test JForm and get a 100% code coverage. I just achieved
> that 10 minutes ago and then went to work on JFormField to get those
> unittests improved.
>
> I'm taking JFormField as an example here, other areas are equally
> horrible. That class has next to no proper unittests! Ok, I can live
> with that, lots of code has been already in the project before we
> started writing unittests somewhere at the end of the 1.6 development.
> But for fucks sake: Why are you still accepting completely new methods
> with large new features without any tests? We had a rule in the past
> that no new code gets added to the libraries folder without proper
> testcoverage.
>
> I can turn a blind eye for the occasional changed or added line of code
> to fix a bug or something, which might show up in the code coverage
> report, but not large new features that are being added like in
> JFormField just 10 days ago. If that rule is not being enforced, I
> wonder why I invest weeks and months of work into writing good tests
> for
> my PRs. I currently feel like I'm not only wasting my time with writing
> those tests, I'm also creating more issues with that for me, since I
> have to not only fix issues that people report when testing, but also
> explain why the tests don't work with my code-change. >:-(
>
> Hannes
>
> --
> You received this message because you are subscribed to the Google
> Groups "Joomla! CMS Development" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to joomla-dev-cm...@googlegroups.com
> <mailto:joomla-dev-cm...@googlegroups.com>.
> To post to this group, send email to joomla-...@googlegroups.com
> <mailto:joomla-...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/joomla-dev-cms.
> For more options, visit https://groups.google.com/d/optout.

Allon Moritz

unread,
Nov 9, 2016, 4:42:01 AM11/9/16
to joomla-...@googlegroups.com
Hannes, I fully agree with your point. Every PR should have unit tests which do test the changes. But we need first a set up in Joomla (proper dependency injection) where we can write unit tests the right way. How it is now, it just doesn't invite you to write tests.

By the way I'v written some integration tests during JAB for custom fields but I think the setup for it is not yet merged into core.


To post to this group, send email to joomla-...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-cms+unsubscribe@googlegroups.com.
To post to this group, send an email to joomla-...@googlegroups.com.

piotr_cz

unread,
Nov 9, 2016, 4:46:26 AM11/9/16
to Joomla! CMS Development
I feel your pain,
but think about it this way: any code committed with unit tests (like yours) has higher quality, is considered more robust and stable

Walt Sorensen aka photodude

unread,
Nov 9, 2016, 12:45:46 PM11/9/16
to Joomla! CMS Development
Hannes,

I appreciate you and everyone else who works on Unit tests. I wish there was better resources to help "the average developer"  be able to write good unit tests for Joomla.
(How to write Joomla Unit tests is a great topic for many many issues of the Joomla magazine)
Reply all
Reply to author
Forward
0 new messages