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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:00:00+00:00 2026-06-03T04:00:00+00:00

I have a a Java class that gets a form definition from database then

  • 0

I have a a Java class that gets a form definition from database then renders html, javascript and css according to the form definition, its using a lot of “appendable.append(…).append(…)” to build the html snippets, which is error prone. Jsp and common templating framework(eg.FreeMarker) is not an option here as the javascript, css, html elements are all dynamic(depending on the form definition). and for some reasons, GWT is not an option either.

A straight forward way of unit testing this renderer is to hard code the expected html code then compare with the actual output, but then the test is very fragile.

What is the best way to unit test this kind of html renderer, please?

Thank you all in advance.

  • 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-03T04:00:01+00:00Added an answer on June 3, 2026 at 4:00 am

    If you hard-code expected HTML values, your tests might be brittle, but they will probably catch most of your bugs. Another approach is to check for the presence of certain key or important tags in the HTML output. This approach is much more flexible, but might miss some bugs. To decide which you should use, consider how often you expect the HTML structure to change.

    There’s a balance to be struck here. The more specific your test is, the most brittle it will be. But if you’re not specific enough, your test won’t catch any bugs. It takes practice to develop of feel for how specific to be.

    However in general, brittle tests are very dangerous so they are probably the “greater evil”. If your tests flag a lot of false positives, you will start to ignore them and then they become useless. I’d suggest you go with verifying the presence of key tags.

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

Sidebar

Related Questions

So I have a class that gets items from a database and then places
I have a standalone Java application that gets data from a database and displays
I have a Java class MyPojo that I am interested in deserializing from JSON.
I'm looking at some Java classes that have the following form: public abstract class
I have java class with a method which gets an image from a website:
I have a Java class: BinaryTree< t > that I am filling from a
I'm currently working on Mangler's Android implementation. I have a java class that looks
I have a simple Java class that I need to serialize to be stored
I have a simple Java class that has some methods: public class Utils {
I am new to Java. I just read that class variables in Java have

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.