[rfc][icedtea-web][policyeditor] Unit tests fix after last PolicyEditor async IO patch

Omair Majid omajid at redhat.com
Tue Jun 3 21:45:52 UTC 2014


* Andrew Azores <aazores at redhat.com> [2014-06-03 17:32]:
> The test itself isn't doing anything async, it's PolicyEditor doing it after
> the SwingWorker patch.

Yup. Due to the aysnc nature, however, the test has no idea that
something is happening. If that thing goes wrong, the test has no way of
finding out.

> The tests used to expect that after instantiating a
> PolicyEditor, once the constructor returned, the editor's model of the
> policy file would already be ready. Now that the file loading is done async
> that assumption doesn't hold, and it's possible for the editor to not have
> parsed the policy file by the time the tests run.

Right, except it there are two things that happening when this test is
run that are a bad idea for a unit test:

- Something is happening async, that the test can not see. Can you allow
  the test to inject some sort of a runner, for example? The test could
  pass a fake thing that causes it to run-in-current-thread, while
  outside the test, it would run in a different thread.

- GUI is being invoked. This may interrupt the user and otherwise make
  things less synchronous (which makes them less reproducible).

> There are already tests for the parsing stage on its own, so
> extracting out the logic into a tests-accessible Runnable would mostly
> just be duplicating the standalone parser tests

You don't have to test the parsing is correct, but it's important to
verify that it happened and that no errors were thrown (for example).

Thanks,
Omair

-- 
PGP Key: 66484681 (http://pgp.mit.edu/)
Fingerprint = F072 555B 0A17 3957 4E95  0056 F286 F14F 6648 4681


More information about the distro-pkg-dev mailing list