Integration test that depends from unit tests.

2,089 views
Skip to first unread message

Konstantin Grigoriev

unread,
May 3, 2012, 10:43:46 AM5/3/12
to simple-b...@googlegroups.com
Hello,

I have a lot of helper methods for tests, which are useful for unit tests, as well as for integration tests. I want to place these helpers near unit tests (in src/test). But integration tests don't have dependency from unit tests.
How can I add such dependency?

Thanks in advance,

Konstantin.

chris

unread,
May 3, 2012, 11:52:56 AM5/3/12
to simple-b...@googlegroups.com
I assume unit tests and integration tests are in different projects.

Then you can add the following dependency:

lazy val integrationTestProject = Project(
 ...
) dependsOn(unitTestProject % "test->test")

Does this help?

Cheers,
  Christian

Konstantin Grigoriev

unread,
May 4, 2012, 6:09:52 AM5/4/12
to simple-b...@googlegroups.com
No, I have single project with unit and integration tests.

четверг, 3 мая 2012 г., 19:52:56 UTC+4 пользователь chris написал:

Mark Harrah

unread,
May 4, 2012, 9:12:35 AM5/4/12
to simple-b...@googlegroups.com
On Fri, 4 May 2012 03:09:52 -0700 (PDT)
Konstantin Grigoriev <konstantin....@gmail.com> wrote:

> No, I have single project with unit and integration tests.

If you are using something like is described in the "Integration Tests" section of the Testing[1] page, you can have your IntegrationTest configuration extend your normal Test configuration. What that means is that it will use the dependencies from Test as well as any declared only for IntegrationTest. This includes the classes from your unit tests.

For example,

lazy val IntegrationTest = config("it") extend(Test)

and use that instead of the default one.

If you are not using the configuration defined on the Testing page, can you share your build definition?

-Mark

[1] https://github.com/harrah/xsbt/wiki/Testing

Konstantin Grigoriev

unread,
May 10, 2012, 8:32:56 AM5/10/12
to simple-b...@googlegroups.com
This is what I needed. Thanks a lot!

пятница, 4 мая 2012 г., 17:12:35 UTC+4 пользователь Mark Harrah написал:

Gabriel Raineri

unread,
Jun 10, 2013, 10:34:27 AM6/10/13
to simple-b...@googlegroups.com
What SBT version are you using?

I've just posted a question where I have a similar issue which used to work fine in 0.11.3 but now I can't make it work in 0.12.2.

The topic is "Custom Test Directories in SBT 0.12.2".

May be you can grab ideas from the config I posted there.

Regards,
Gabriel

On Monday, June 10, 2013 11:10:34 AM UTC-3, Martin wrote:
I have exactly the same problem. I want to use helper classes from src/test/scala in src/it/scala in the same project.

When I use:

lazy val root =
  Project("root", file("."))
    .configs( config("it") extend(Test) )
    .settings( Defaults.itSettings : _*)
then src/it/scala indeed compiles, but when I execute "it:test", the tests from src/test/scala are run, not the integration tests in src/it/scala.

I tried using

   lazy val itConfig = config("it") extend(Test)
lazy val root =
  Project("root", file("."))
    .configs( config("it") extend(Test) )
    .settings( inConfig(itConfig)(Defaults.testSettings) : _*)
and also, inConfig(itConfig)(Defaults.itSettings), but no luck - "it:test" never executes anything. "show it:sources" shows the correct sources though so I'm really confused.
Thanks for any pointers!

Martin

unread,
Jun 10, 2013, 10:44:16 AM6/10/13
to simple-b...@googlegroups.com
I'm on 0.12.0. When I run both "it:test" and "test:test", the same tests (under src/test/scala) are run.
But the problem is similar to yours in the way that "it:test" doesn't see the correct tests, even though "show it:sources" correctly lists the sources under src/it/scala.

Gabriel Raineri

unread,
Jun 10, 2013, 10:46:27 AM6/10/13
to simple-b...@googlegroups.com
I see and I agree that there's certain similarity. 

In fact, if I change the settings for my integration tests I have the same behavior as you (both test:test and it:test end up running the same tests)

Mark Harrah

unread,
Jun 10, 2013, 11:49:20 AM6/10/13
to simple-b...@googlegroups.com
On Mon, 10 Jun 2013 07:10:34 -0700 (PDT)
Martin <martin....@commercetools.de> wrote:

> I have exactly the same problem. I want to use helper classes from
> src/test/scala in src/it/scala in the same project.
>
> When I use:
>
> lazy val root = Project("root", file("."))
> .configs( config("it") extend(Test) )
> .settings( Defaults.itSettings : _*)
>
> then src/it/scala indeed compiles, but when I execute "it:test", the tests
> from src/test/scala are run, not the integration tests in src/it/scala.
>
> I tried using
>
> lazy val itConfig = config("it") extend(Test)
>
> lazy val root = Project("root", file("."))
> .configs( config("it") extend(Test) )
> .settings( inConfig(itConfig)(Defaults.testSettings) : _*)
>
> and also, inConfig(itConfig)(Defaults.itSettings), but no luck - "it:test" never executes anything. "show it:sources" shows the correct sources though so I'm really confused.
>
> Thanks for any pointers!

This is the same issue as the other thread. There was a bug introduced by the support for forked tests:

https://github.com/sbt/sbt/issues/539

It has been fixed in 0.13 and I think the workaround in 0.12 is:

testGrouping in IntegrationTest <<= definedTests in IntegrationTest map partitionTests

-Mark

>
>
> On Friday, May 4, 2012 3:12:35 PM UTC+2, Mark Harrah wrote:
> >
> --
> You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to simple-build-t...@googlegroups.com.
> To post to this group, send email to simple-b...@googlegroups.com.
> Visit this group at http://groups.google.com/group/simple-build-tool?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Martin Konicek

unread,
Jun 10, 2013, 12:14:48 PM6/10/13
to simple-b...@googlegroups.com
Thank you Mark!


You received this message because you are subscribed to a topic in the Google Groups "simple-build-tool" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/simple-build-tool/Dw9rUhk2hOw/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to simple-build-t...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages