On Sun, Jan 17, 2010 at 6:10 PM, Sean Owen <sro...@gmail.com> wrote:

> There are already cases where code needs to control the seed (mostly
> to serialize/deserialize the exact state of an object).
>

That is an important case, but it should be deterministic and thus not a
problem for testing.  Really the RNG is being used more as a good hash
function in these cases.


> I don't think
> that's the issue per se?
>

I don't think that the serialization trick is a problem at all.


> The issue is when an RNG lives beyond one
> test, and there are legitimate reasons that may be so.
>

Hmm... I can't think of any off-hand.  You probably have something in mind.

Can you say what reasons there are for this?


> I don't see how a getTestRandom() method fixes something... I can't
> call this in my non-test code, and then tests can't control those
> RNGs. The non-test code can't make this decision which is why they
> don't. I don't think this is the problem/solution but rather having a
> way to globally reset all RNGs.
>

I think that the problem that we are talking around here is whether we
commit to having RNG's be injectable whereever they are used.   Half
measures are the problem here (IMHO).  Real injection would solve all the
questions by giving complete control to the test case.  I don't think that
we need Guice or Spring here, just a way to say "use this RNG, if you don't
mind".

Reply via email to