renatoathaydes / Automaton

Simple framework which allows the testing of Swing and JavaFX2 applications.
Apache License 2.0
100 stars 21 forks source link

JUnit isn't recognizing AssertionErrors (Version 1.3.2) #53

Open cdaqua opened 7 years ago

cdaqua commented 7 years ago

I'm working with NetBeans 8.2 and the latest JUnit plugin. I have a JUnit method that looks like this

@Test
public void myTest()  {
    AutomatonScriptRunner.getInstance().run(scriptPath, null);
}

If my script fails a message is written to standard output but in my "Test Results" window the test has passed. I had a look into "src\main\groovy\com\athaydes\automaton\cli\AutomatonScriptRunner.groovy" where all Throwables are caught. Then added the line throw e at the end of the catch closure, compiled and used this modified version in my project and now it works just fine!

So my question is: What are the reasons for the current AssertionError handling since it isn't working properly with frameworks like JUnit?

renatoathaydes commented 7 years ago

AScripts are runnable from Java agents, so we can't just throw an error from the script runner otherwise that would kill the agent.

I wrote a blog post about using AScript from JUnit: https://sites.google.com/a/athaydes.com/renato-athaydes/posts/usingautomatontotestajavafx8app#TOC-Using-JUnit-or-any-other-test-framework-

Unfortunately, I never took the time to make improvements to this, so currently you need to capture the output of the AScript as I explain in that post.