DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > Integrating SureAssert with Existing Projects

Integrating SureAssert with Existing Projects

Roger Hughes user avatar by
Roger Hughes
·
Oct. 07, 11 · Java Zone · Interview
Like (0)
Save
Tweet
4.06K Views

Join the DZone community and get the full member experience.

Join For Free

I recently blogged about SureAssert’s ability to do automatic, continuous, declaration driven testing using annotations, which could make JUnit test classes obsolete. When picking up any new and useful development tool, the first question asked is usually “how can it help my existing project?” The answer here is that SureAssert integrates with existing JUnit test code, which gives you the benefit of having your existing JUnit tests continuously monitored and executed.

To integrate SureAssert with an existing project, you’ll need to add the SureAssert Annotation jar file, which is currently: org.sureassert.uc.annotation-1.1.0.jar, to your project. This JAR file isn’t currently available from Maven Central, so you’ll need to add it manually to your local repository using the maven install file command. You’ll need to execute something like:

mvn install:install-file -DgroupId=sureassert -DartifactId=annotations -Dversion=1.1.0 -Dpackaging=jar -Dfile={path to}/org.sureassert.uc.annotation-1.1.0.jar

Having made this JAR file available to your application, the next step is to annotate the classes that you want SureAssert to monitor. Going back to the Calculator example used in my last blog, then for SureAssert to pick-up Calculator's JUnit test class, CalculatorTest, you'll need to add the following annotation to your Calculator class:

@HasJUnit(jUnitClassNames = "com.sureassert.uc.tutorial.mytests.CalculatorTest")
public final class Calculator {

  @UseCase(args = { "1", "2" }, expect = "3")
  public int add(int x, int y) {

    return x + y;
  }

  @UseCase(name = "multiplyTest", args = { "4", "2" }, expect = "8")
  public int multiply(int x, int y) {

    return x * y /* + 1 */;
  }

  /**
   * This method is served by a JUnit test
   */
  public int subtract(int x, int y) {

    return x - y;
  }

}

Note that’ll you need the fully qualified class name of your JUnit test as an attribute to the HasJUnit annotation.

The SureAssert plugin with then automatically run the CalculatorTest JUnit when necessary and test failures will be shown as errors:


If your tests follow the FIRST acronym, and your tests are fast then attaching @HasJUnit is a good idea. I would suspect that badly written, slow and end to end tests may make eclipse run slowly. This this case, don’t blame SureAssert, take a look at your tests...

 

From http://www.captaindebug.com/2011/09/integrating-sureassert-with-existing.html

Testing

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • SDLC Vs STLC: What's the Difference?
  • This Is How You Give Good Feedback at Work
  • Modernizing Testing With Data Pipelines
  • Suspicious Sortings in Unity, ASP.NET Core, and More

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo