Unit testing a Swing component

后端 未结 5 1855
清歌不尽
清歌不尽 2021-02-19 22:25

I am writing a TotalCommander-like application. I have a separate component for file list, and a model for it. Model support listeners and issues a notification for events like

5条回答
  •  悲哀的现实
    2021-02-19 23:09

    I think the problem with testing is revealing a problem with the code. It shouldn't really be the model's job to decide whether it's running in the dispatch thread, that's too many responsibilities. It should just do its notification job and let a calling component decide whether to call it directly or to invokeLater. That component should be in the part of the code that knows about Swing threads. This component should only know about files and such.

提交回复
热议问题