Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing GUI with JUnit

Tags:

java

junit

scala

Well, we all know test-driven development. I'd need to write a GUI-based library, but to be honest, I always neglected the testing. Did JUnit for university and such, but we never got any deeper than the usual "Implement a list and test it."

So, since I don't want to write a thousand applications for the features, I'd like to know, what's the "professional" approach to GUI-based library testing with Scala and JUnit?

Thanks for listening.

like image 679
Lanbo Avatar asked Feb 26 '23 15:02

Lanbo


2 Answers

Separate your Presentation layer from everything else.

Keep the Presentation layer as thin as possible so that testing can in theory take place within a middle-man of a given pattern; MVC, MVVM, etc...

The moment you begin to couple the Presentation layer with underlying logic your testing will become a nightmare to maintain as well as execute.

At the end of thoroughly testing your Models/ViewModels/Controllers, etc...testing the Presentation layer can often times lose its highly regarded value. Is it still valuable? Yes...but the return has diminished considerably.

These concepts apply to many frameworks/languages. Once you grasp this understanding the technological benefits of a given framework/language will surface naturally. Do not rely on the framework/language to answer this though. A framework/language can definitely lend itself to provide separation of concerns in a much more friendly manner however the separation of concerns is and has always been at the forefront of any type of testing; GUI included.

like image 70
Aaron McIver Avatar answered Mar 07 '23 00:03

Aaron McIver


Read the book Test Driven a practical TDD and acceptance TDD for java developpers.

It covers the basics on how to unit-test Swing Applications and also some TDD techniques.

I haven't finished the book so i don't know if it covers Scala but i highly recommend this book (already)!

Some personal note : if you want action skip chapter one but return back to it. It covers the "How to start using TDD in general"

Test Driven book link

like image 29
David Avatar answered Mar 07 '23 00:03

David