The problem with that original position is that it overloads testing to
include both testing the auth app's implementation and testing the
user's configuration when they're using the auth app. So there are
definitely two legitimate sides to that opinion.
I much prefer self-contained unittests. I read Russell's mail as
preferring to trade that for installation/configuration testing. I don't
particularly agree with that, but I could live with it if we decide it's
the way we want to go.
> but rev 8497
> introduces a test only template directory [2] which
>
> a) causes the tests to pass in the absence of an actual login template
> (the provided template is not a default template, it's a test
> template);
It also means the tests pass as a self-contained bundle to test the auth
app, rather than requiring a user using the auth app to have to set up
all these templates even if they're not using a particular piece of the
auth app just to have the tests pass. That's not a trivial concern.
There is a middle ground here, which is that those auth-app templates
get moved to the Django's main test directory so that they're available
only to runtests. That doesn't feel particularly self-contained and
again, for me, violates the intuitive meaning of the word unittest, but
it's the way we've gone with the new comment tests and the admin tests,
for example. Might be a trend to follow.
Malcolm
I suppose this just serves to highlight that there are two types of
testing that need to be performed - application tests and integration
tests. While the unittest framework is certainly well suited to
application testing, in a (semi) controlled environment like a Django
project it can also be quite useful for integration testing.
In a complete system, both forms of testing are required, which means
a complete reusable application should have two tests:
1) a test that the views work as expected when a known correct
template is provided
2) a test that the view works as expected with the template that has
been provided by the project (which is also a test that the required
templates are available).
The self-contained approach to testing is essentially case (1). This
is fine, but you still need to write a test for (2).
A well written 'template external' test _should_ validate both cases
when it passes. There are some weakness to this argument - if you get
a failure, it doesn't help you narrow down if the problem is your
template or the application logic, and there is the outside
possibility that a bad template could somehow cause the test to pass
(although I can't think of an easy way that this would happen) - but
as a general argument, it should hold.
The failure case isn't that bad, though, because there are two people
that will run the test -
* The application developer
* The end user
The application developer should have a good set of templates in their
test harness (such as Django's templates in the system test folder),
and if a failure is observed, the app developer is in the best
position to sort out the source of the failure.
End users should be able to trust their app providers to be testing
and tagging releases only when tests pass; if an end user is seeing a
failure, it's a reasonable assumption that the failure is template
related. As a side note, if the end user trusts their provider, there
is almost no reason for the end user to run type (1) application tests
(case in point - how often do non-core devs run the Django test suite?
How often to Django core devs run the MySQL test suite?)
Of course, the ideal solution would be a good answer for the problem
of supporting both application and integration tests, but that's part
of a much bigger discussion.
>> but rev 8497
>> introduces a test only template directory [2] which
>>
>> a) causes the tests to pass in the absence of an actual login template
>> (the provided template is not a default template, it's a test
>> template);
>
> It also means the tests pass as a self-contained bundle to test the auth
> app, rather than requiring a user using the auth app to have to set up
> all these templates even if they're not using a particular piece of the
> auth app just to have the tests pass. That's not a trivial concern.
The missing piece here is something that I have raised in the
discussion around #7611 - there will be tests that should be skipped
as part of the suite if the feature they are testing isn't actually
deployed in a project. For example, if you're not deploying the
password change view you don't need to run tests that check that the
password change view work is working correctly. Devin Naquin (from
Disqus) did some initial work in this area around ticket #4788; I
haven't had a chance to look into his patches yet, but it's on my todo
list once we get 1.0 finished.
> There is a middle ground here, which is that those auth-app templates
> get moved to the Django's main test directory so that they're available
> only to runtests. That doesn't feel particularly self-contained and
> again, for me, violates the intuitive meaning of the word unittest, but
> it's the way we've gone with the new comment tests and the admin tests,
> for example. Might be a trend to follow.
To my mind, moving the templates to the django test directory is the
right solution in this case. The Django system tests need to validate
that the auth system works when the right templates are available, so
it needs to provide those templates.
Unfortunately, this means that the auth tests will fail for users that
aren't providing auth templates. I realize that this isn't an ideal
outcome, but my gut feeling is that the benefit to users knowing their
installs are busted is greater than the pain for those users that will
have known test failures due to not deploying some views and
templates.
Yours,
Russ Magee %-)