These are chat archives for etorreborre/specs2

31st
Jan 2019
Eric Torreborre
@etorreborre
Jan 31 07:12
@edmondo1984 the support for GWT is unfinished business in specs2 because I never felt like using it. The main reason is that I want to be able to rely on Scala as much as possible to catch inconsistencies for me whereas Gherkin is just some text that might not parse ok. So what you wrote with steps and examples is closer to what I like and you can use DataTables inside. Now you’re saying that the error reporting is not good for steps (but t1 is an example not a step), I need to reproduce that. What I would propose is that you setup a small demo project so that we can work of both error reporting and the syntax until you achieve exactly what you want
Edmondo Porcu
@edmondo1984
Jan 31 10:04
@etorreborre thank you I will publish a blog post about it
I think I came up with some smart ways to do that in Specs2, really nice. I have a single question, how would you ensure a certain "piece" is setup only once across several tests?
Eric Torreborre
@etorreborre
Jan 31 10:09
You mean some setup that only executes for a subset of all the test classes when you run sbt test?
Edmondo Porcu
@edmondo1984
Jan 31 10:11
For example, yes
Edmondo Porcu
@edmondo1984
Jan 31 10:21
I have to initialize an h2db in memory and set up a certain infrastructure, and it takes too much time
Edmondo Porcu
@edmondo1984
Jan 31 11:53
Also when I build the following specification, I have a "found : org.specs2.specification.core.Fragment
[error] required: org.specs2.specification.create.InterpolatedFragment" error
         Given I started the process manager for company data collection $g1
         $whenLabel $w1
         Then some data should be collected $t1
Eric Torreborre
@etorreborre
Jan 31 13:20
generally if you need to setup an in-memory database you can put that code in a lazy val in an object shared by several specifications. Otherwise I don’t understand the error above without more information, imports, line of code where the error is, etc...
Edmondo Porcu
@edmondo1984
Jan 31 13:54
@etorreborre what about the shutdown?
sbt:business-information-collector> test:compile
[info] Compiling 24 Scala sources to /Users/edmondoporcu1/Development/credimi/business-information-collector/target/scala-2.12/test-classes ...
[error] /Users/edmondoporcu1/Development/credimi/business-information-collector/src/test/scala/com/credimi/businessinformation/collector/companydata/CollectCompanyDataProcessManagerTest.scala:36:75: type mismatch;
[error]  found   : org.specs2.specification.core.Fragment
[error]  required: org.specs2.specification.create.InterpolatedFragment
[error]          Given I started the process manager for company data collection $g1
[error]                                                                           ^
[error] /Users/edmondoporcu1/Development/credimi/business-information-collector/src/test/scala/com/credimi/businessinformation/collector/companydata/CollectCompanyDataProcessManagerTest.scala:37:11: type mismatch;
[error]  found   : String
[error]  required: org.specs2.specification.create.InterpolatedFragment
[error]          $whenLabel $w1
[error]           ^
[error] /Users/edmondoporcu1/Development/credimi/business-information-collector/src/test/scala/com/credimi/businessinformation/collector/companydata/CollectCompanyDataProcessManagerTest.scala:37:22: type mismatch;
[error]  found   : org.specs2.specification.core.Fragment
[error]  required: org.specs2.specification.create.InterpolatedFragment
[error]          $whenLabel $w1
Eric Torreborre
@etorreborre
Jan 31 13:54
That’s trickier :-). In the past I have been using a sbt hook to do this IIRC
I think you are missing some implicits in your scope
What do you think about this? Can this be used to initialize an object and shut it down in a single jvm?
Eric Torreborre
@etorreborre
Jan 31 13:56
yes that’s the trick
Edmondo Porcu
@edmondo1984
Jan 31 13:56
let me see, in the code where it works I am mixing ActionDsl and S2StringContextCreation
and I am importing MustMatchers._
Edmondo Porcu
@edmondo1984
Jan 31 14:43
but I am doing the same in the other spec
Eric Torreborre
@etorreborre
Jan 31 15:28
Without seeing the project I don’t know what’s going on, sometimes an implicit could silently be cancelled out by another one. This is all a fragile construction, if you cherry-pick some traits in the Specification hierarchy some things might not work
Edmondo Porcu
@edmondo1984
Jan 31 15:36
So the thing is that if I do not pick this, then the sbt runner will try to run Specifications even when they have constructor argoments
and it will blow up happily
but I got the point and I will try to make it explicitly it makes sense