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 6008979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:54:19+00:00 2026-05-23T01:54:19+00:00

The rewritten specs2 testing framework for Scala integrates automated testing with scalacheck . The

  • 0

The rewritten specs2 testing framework for Scala integrates automated testing with scalacheck. The examples given in the specs2 documentation on how to use scalacheck together with specs2 either use integers or more complicated custom generators as in eric’s json example.

While trying to get a slightly less complicated example working, I’m struggling because I don’t know how one would use specs2 and scalacheck if I want to generate String arguments instead of Integers. How would this Quickstart example


import org.scalacheck._

object StringSpecification extends Properties("String") { property("startsWith") = Prop.forAll((a: String, b: String) => (a+b).startsWith(a))

property("endsWith") = Prop.forAll((a: String, b: String) => (a+b).endsWith(b))

// Is this really always true? property("concat") = Prop.forAll((a: String, b: String) => (a+b).length > a.length && (a+b).length > b.length )

property("substring") = Prop.forAll((a: String, b: String) => (a+b).substring(a.length) == b )

property("substring") = Prop.forAll((a: String, b: String, c: String) => (a+b+c).substring(a.length, a.length+b.length) == b ) }

taken from the scalacheck homepage look, if it was written as Specs2 specification using the scalacheck integration?

  • 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-05-23T01:54:19+00:00Added an answer on May 23, 2026 at 1:54 am

    A very direct translation is using the check method and simple functions:

    package test
    
    import org.specs2._
    import org.scalacheck._
    
    class ScalaCheckExamples extends Specification with ScalaCheck { def is =
    
      "startsWith" ! check { (a: String, b: String) => (a+b).startsWith(a) }                                                ^
      "endsWith"   ! check { (a: String, b: String) => (a+b).endsWith(b) }                                                  ^
      "concat"     ! check { (a: String, b: String) => (a+b).length > a.length && (a+b).length > b.length }                 ^
      "substring"  ! check { (a: String, b: String) => (a+b).substring(a.length) == b }                                     ^
      "substring"  ! check { (a: String, b: String, c: String) => (a+b+c).substring(a.length, a.length+b.length) == b }     ^
                                                                                                                            end
     }
    

    And the output actually shows that the concat property is not correct:

      [info] + startsWith
      [info] + endsWith
      [error] x concat
      [error]   A counter-example is ['', ''] (after 0 try)
      [error] the value is false
      [error]  (ScalaCheckExamplesSpec.scala:6)
      [info] + substring
      [info] + substring
      [info]
      [info] Total for specification ScalaCheckExamplesSpec
      [info] Finished in 7 seconds, 547 ms
      [info] 5 examples, 401 expectations, 1 failure, 0 error
      [info]
    

    Eric.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our website was recently rewritten in the Play framework. We offer file downloads to
I've read loads of examples in which <li><%= Html.ActionLink(Home, Index, Home)%></li> is rewritten as
I've written a NaturalComparator class/object in Java and rewritten it into Scala: https://gist.github.com/319827#file_natural_comparator.scala However,
Given: old ugly urls like /somepage?ln=en are rewritten in htaccess to /en/somepage Given: used
a short question about optional regex : imagine a given page thats currently rewritten/beautified
Question Rewritten: HOMEDIR=ftpuser REMOTEIP=1.1.1.1 MYSQLPASS=password Q1=DROP USER $HOMEDIR_shop; Q2=DROP DATABASE $HOMEDIR_shop; Q3=CREATE DATABASE IF
I see often (rewritten) URLs without ID in it, like on some wordpress installations.
I've rewritten my family web site using JavaScript (JQuery) making Ajax calls to PHP
So have rewritten my ugly php URL to something prettier: RewriteEngine On RewriteRule ^main/photo([^/\.]+)/?.html$
I have rewritten an old program and designed a new database for it. I

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.