Running on Java 21-ea+24-2086 (Preview)
Home of The JavaSpecialists' Newsletter

2.22 Testing Before Running Application

Juppies 2 by Dr Heinz M. Kabutz

We had the issue before that we made a mistake in our code which would have been discovered by our unit test. However, when we started the game, the tests were not automatically run. I asked the NetBeans project manager, and he said "ah, just set it up in the project properties". I had no idea how to do that. I had looked at the precise place he suggested, but I did not realise that this was the way to solve my problem. NetBeans is the most flexible Java IDE there is, and we can make it do almost anything. We just need to know how :-) Here is how it works:

When we call "Run" it calls a specific task. When we select Project Properties and go to Actions, we then look for the Action "Run project". Click on it, and the "Execute Goals" shows what steps will be taken to run our game. After the "process-classes" we simply add "test" and then every time we run our game, the tests are also automatically called. Now when we run our game, it won't even try start it until all the tests have passed. Easy as pie!

Comments

When you load these comments, you'll be connected to Disqus. Privacy Statement.

Table of Contents

We hope you enjoyed this tutorial. If you did, you will also enjoy our courses. We suggest you start with Extreme Java - Advanced Java, followed by Extreme Java - Concurrency Performance for Java 8.



About the Author

Heinz Kabutz Java Conference Speaker

Java Champion, author of the Javaspecialists Newsletter, conference speaking regular... About Heinz

Superpack '23

Superpack '23 Our entire Java Specialists Training in one huge bundle more...

Free Java Book

Dynamic Proxies in Java Book
Java Training

We deliver relevant courses, by top Java developers to produce more resourceful and efficient programmers within their organisations.

Java Consulting

We can help make your Java application run faster and trouble-shoot concurrency and performance bugs...

Java Emergency?

If your system is down, we will review it for 15 minutes and give you our findings for just 1 € without any obligation.