Quantcast

rebar and eunit test prep

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

rebar and eunit test prep

Joel Reymont
Suppose my eunit tests require mnesia to be started and a schema to be installed.

How do I incorporate that into ./rebar eunit such that the setup above is done only once?

I definitely don't want to start mnesia and install the schema before every test.

        Thanks, Joel

--------------------------------------------------------------------------
- for hire: mac osx device driver ninja, kernel extensions and usb drivers
---------------------+------------+---------------------------------------
http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
---------------------+------------+---------------------------------------



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: rebar and eunit test prep

Bob Ippolito
On Wed, Jun 22, 2011 at 12:14 PM, Joel Reymont <[hidden email]> wrote:
> Suppose my eunit tests require mnesia to be started and a schema to be installed.
>
> How do I incorporate that into ./rebar eunit such that the setup above is done only once?
>
> I definitely don't want to start mnesia and install the schema before every test.

Take a look at the {setup, ...} fixture [1] and put all of the
Mnesia-requiring tests in there. Alternatively you can use meck or
another mocking module to stub out Mnesia calls if that makes sense
for some of the tests.

[1] http://www.erlang.org/doc/apps/eunit/chapter.html#Fixtures

-bob
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: rebar and eunit test prep

Eric Merritt-2
In reply to this post by Joel Reymont
Bob has advice for how to do this in rebar.

However, you want your unit tests to be small and focused. They
shouldn't need mnesia started to run, mock up the mnesia calls with
meck.

These are more integration tests then unit tests, for that use
something along the lines of common test.

This distinction between self contained unit tests that just focus on
the module functionality and then broader integration tests is an
important one.

Eric

On Wed, Jun 22, 2011 at 2:14 PM, Joel Reymont <[hidden email]> wrote:

> Suppose my eunit tests require mnesia to be started and a schema to be installed.
>
> How do I incorporate that into ./rebar eunit such that the setup above is done only once?
>
> I definitely don't want to start mnesia and install the schema before every test.
>
>        Thanks, Joel
>
> --------------------------------------------------------------------------
> - for hire: mac osx device driver ninja, kernel extensions and usb drivers
> ---------------------+------------+---------------------------------------
> http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
> ---------------------+------------+---------------------------------------
>
>
>
> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions
>
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: rebar and eunit test prep

Joel Reymont

On Jun 22, 2011, at 8:42 PM, Eric Merritt wrote:

> However, you want your unit tests to be small and focused. They
> shouldn't need mnesia started to run, mock up the mnesia calls with
> meck.

True. I've been using eunit for integration tests with OpenPoker.

> These are more integration tests then unit tests, for that use
> something along the lines of common test.

Any existing projects (github) that use common test?

        Thanks, Joel

--------------------------------------------------------------------------
- for hire: mac osx device driver ninja, kernel extensions and usb drivers
---------------------+------------+---------------------------------------
http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
---------------------+------------+---------------------------------------



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: rebar and eunit test prep

Tim Watson-5
On 22 June 2011 20:43, Joel Reymont <[hidden email]> wrote:
> True. I've been using eunit for integration tests with OpenPoker.
>
>> These are more integration tests then unit tests, for that use
>> something along the lines of common test.
>
> Any existing projects (github) that use common test?

https://github.com/hyperthunk/hamcrest-erlang uses common_test as a
bootstrap for proper. :)

I use common_test more often than not, just out of habit really as I
never bothered to get into eunit. Eventually I started to include the
eunit.hrl header and use the assert macros in my common_test suites,
until finally I started using hamcrest instead. I'm getting more into
quickcheck/proper now, which can be combined with all of the above.
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: rebar and eunit test prep

Lukas Larsson-3
In reply to this post by Joel Reymont

All of the Erlang/OTP tests also use common_test if you are looking for examples.

On Jun 22, 2011 9:43 PM, "Joel Reymont" <[hidden email]> wrote:
>
> On Jun 22, 2011, at 8:42 PM, Eric Merritt wrote:
>
>> However, you want your unit tests to be small and focused. They
>> shouldn't need mnesia started to run, mock up the mnesia calls with
>> meck.
>
> True. I've been using eunit for integration tests with OpenPoker.
>
>> These are more integration tests then unit tests, for that use
>> something along the lines of common test.
>
> Any existing projects (github) that use common test?
>
> Thanks, Joel
>
> --------------------------------------------------------------------------
> - for hire: mac osx device driver ninja, kernel extensions and usb drivers
> ---------------------+------------+---------------------------------------
> http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
> ---------------------+------------+---------------------------------------
>
>
>
> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Loading...