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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:44:05+00:00 2026-05-14T07:44:05+00:00

I am currently working on a module that takes one of our business objects

  • 0

I am currently working on a module that takes one of our business objects and returns a json representation of that object to the caller. Due to limitations in our environment I am unable to use any existing json writer, so I have written my own, which is then used by the business object writer to serialize my objects. The json writer is tested in a way similar to this

@Test
public void writeEmptyArrayTest() 
{
   String expected = "[  ]";
   writer.array().endArray();
   assertEquals(expected, writer.toString());
}

which is only manageable because of the small output each instruction produces, even though I keep feeling there must be a better way.

The problem I am now facing is writing tests for the object writer module, where the output is much larger and much less manageable. The risk of spelling mistakes in the expected strings mucking up my tests seem too great, and writing code in this fashion seems both silly and unmanageable in a long term perspective. I keep feeling like I want to write tests to ensure that my tests are behaving correctly, and this feeling worries me.

What is a better way of doing this?

  • 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-14T07:44:05+00:00Added an answer on May 14, 2026 at 7:44 am

    Technically the environment in which you are deploying your code is not the same as the environment in which you are developing it so I would use an existing JSON reader/writer to test the one you have created. If you are using maven, you can even set the scope of the JSON package you choose to use to be “test” so it will not be included in the actual build.

    <dependency>
      <groupId>org.json</groupId>
      <artifactId>json</artifactId>
      <version>20090911</version>
      <scope>test</scope>
    </dependency>
    

    Alternatively, you can have your unit test inherit from your JSON writer. By inheriting, you can test all the protected and private internal bits instead of checking the actual String output.

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

Sidebar

Related Questions

I am currently working on an Apache module that uses a large mmap file
I am currently working on a marketing module that keeps track of sites that
Possible Duplicate: Optional Output Parameters I am currently working in a module wherein I
Currently working with converting SQLException error messages into messages that are more useful for
Currently working for the first time with JSON and with little experience of jQuery.
Im currently working on a game that uses multi touch to apply zoom to
I'm currently working on a project that involves moving a database of documents for
I am currently working on a code base, that has never had any unit
I'm currently working on a custom module in which I have a controller extending
Im currently working on a Python/Pygame module to wrap some basic sprite animation. Animation

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.