Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8541373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:49:01+00:00 2026-06-11T11:49:01+00:00

specs2 has traits such as Before , After , Around , etc. in order

  • 0

specs2 has traits such as Before, After, Around, etc. in order to be able to wrap examples in setup/teardown code.

Is there anything to support setting up and tearing down testing infrastructure for each “iteration” of a ScalaCheck property, i.e. each value or set of values to be tested by ScalaCheck?

It looks like specs2’s various Before, After, Around traits are designed around returning or throwing specs2 Result instances, and a Prop isn’t a Result.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:49:02+00:00Added an answer on June 11, 2026 at 11:49 am

    This is fixed now in the latest 1.12.2-SNAPSHOT. You can now write:

    import org.specs2.ScalaCheck
    import org.specs2.mutable.{Around, Specification}
    import org.specs2.execute.Result
    
    class TestSpec extends Specification with ScalaCheck {
      "test" >> prop { i: Int =>
        around(i must be_>(1))
      }
    
      val around = new Around {
        def around[T <% Result](t: =>T) = {
          ("testing a new Int").pp
          try { t }
          finally { "done".pp }
        }
      }    
    }
    

    And this will execute code before and after the “body” of the Property.

    You can also go a step further and create a support method to pass in an implicit around to your Props:

    class TestSpec extends Specification with ScalaCheck {
      "test" >> propAround { i: Int =>
        i must be_>(1)
      }
    
      // use any implicit "Around" value in scope
      def propAround[T, R](f: T => R)
                          (implicit a: Around, 
                           arb: Arbitrary[T], shrink: Shrink[T], 
                           res: R => Result): Result =
        prop((t: T) => a(f(t)))
    
      implicit val around = new Around {
        def around[T <% Result](t: =>T) = {
          ("testing a new Int").pp
          try { t }
          finally { "done".pp }
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code working with a DataGrid that has two column Column_A
I know this question has been asked before, I'm just trying to be absolutely
I'm trying to test-drive some Scala code using Specs2 and Mockito. I'm relatively new
My BlackBerry code signing has started to fail with an Error connecting to web
I have written a ScalaCheck test case within Specs2. The test case gives up
I'm trying to test a model method using Play Framework 2.0 and Specs2. Global.scala
It's a CentOS server (I don't know the specs) and just before anybody states
I've been developing a Silverlight-c# client-server game that has now gotten to the point
One of my clients has mentioned the term 'Database House Keeping' in his tender
Jquery Mobile has decided to treat anchor links as page requests of sort. However,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.