[erlang-questions] Mocks and explicit contracts

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Thu Nov 19 16:44:30 CET 2015


Another solution again is to run all the tests in parallel and then
afterwards you make a reconstruction in which you ask the question "Can I
reconstruct a trace from the observations I made?" That solution is
sometimes easier to pull off, though the reconstruction can be
computationally expensive in the general case.

This is, more or less, what you would do in a property based testing
solution.


On Thu, Nov 19, 2015 at 4:39 PM, José Valim <jose.valim@REDACTED
> wrote:

> The latter do work, though, IFF all concerned tests are just expecting the
>> same thing from the called function... but most likely you have some tests
>> that would check different scenarios. One test might check that the System
>> Under Test behaves well if twitter does a positive response while another
>> might check that the SUT  does  not fail in a catastrophic way if the
>> twitter call gives garbage as response.
>>
>
> Yes. One solution to this problem is to parameterize the different
> responses under the same system. For example, the username request for
> "josevalim" would work but fail for "josevalim-fail". It is a very simple
> solution but it can get unwieldy for complex systems where you need to test
> many scenarios. In any case, I wouldn't discard this approach quickly, as
> it fits simple problems quite well.
>
> A more complex solution is to have an ownership pool where you could say:
> "if this pid asks for this data, return this value". The benefit of such
> system is that, if a pid has a given key reassigned without first
> "deallocating" it, you certainly have a concurrency issue in your tests
> where two tests need the same resource. We are building such system to
> allow us to run tests concurrently even if they depend on a common external
> resource like a database. We replace the regular database pool by the
> ownership pool and run tests concurrently by wrapping each connection in a
> transaction (works for SQL ones) or by running different database instances.
>
>
> *José Valim*
> www.plataformatec.com.br
> Skype: jv.ptec
> Founder and Director of R&D
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>


-- 
J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20151119/e74452f6/attachment.htm>


More information about the erlang-questions mailing list