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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:02:37+00:00 2026-06-04T11:02:37+00:00

I’m working on a new project, where I want to display some data on

  • 0

I’m working on a new project, where I want to display some data on the screen. I set myself to using TDD which is new for me, but I love the idea and get along quite OK so far.

I set up a JFrame, add a Textarea and put text there, but how can I properly test this? Or is this wrong thinking in the TDD context on my side? I want to be sure (in the TDD way), that the data gets displayed correctly! The creation of the text that gets displayed is properly covered with tests, but the displaying is not.

Here is a completely simplified example:

public class MyTextDisplay {
    public static void main(String[] args) {
        JFrame my_frame = new JFrame("DisplaySomeText");
        my_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JTextArea textArea = new JTextArea(5, 20);
        textArea.setEditable(false);

        my_frame.add(textArea);
        my_frame.setVisible(true);

        //this would be in a separate method
        textArea.append("Hello World");
    }
}
  • 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-04T11:02:38+00:00Added an answer on June 4, 2026 at 11:02 am

    TDD requires you to think about things a little bit differently. You first determine what you are going to test, and how you are going to test it before you actually write any code for the solution.

    For GUI’s, this can become quite tricky, and, in all honesty, your GUI should never contain any logic that could be in a separate layer. For example, the value that is displayed should come from an object that has nothing to do with the GUI, but that can be tested individually. That allows you to develop the main business logic (model and controller) separate from the display (view). This is the MVC pattern. Test Driven Development simply means that you test what you can before you write code, and, as you add more code, more tests will start to pass.

    I’d rather focus on my design and ensure that whatever is generating the text value works as expected. The GUI should be “dumb” and only focus on displaying or retrieving values, with little, if any concern for if the displayed values are indeed correct.

    As a GUI is notoriously difficult to test with automated tools (properly test), I’d avoid that as much as possible and decouple my GUI from my actual application as much as I can. Then you can test the GUI once, to make sure it displays what it’s supposed to, and focus on the business logic without having to do continuous tests on the GUI as you are not touching that code.

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

Sidebar

Related Questions

I want to construct a data frame in an Rcpp function, but when I
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
i want to parse a xhtml file and display in UITableView. what is the
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.