testing

Testing tools, testing philosophy & methodology...
johanmynhardt 2020-07-14T10:50:41.067600Z

Hello 🙂 I am about to lose hope that what I'm attempting to do is not possible "out of the box". I've been through many SO-posts, github projects and many hours of Googling. I'm new to Clojure testing and was hoping to be able to write end-to-end tests. I'm having small successes in that I have managed to get some form of usable output to junit XML. Getting "pretty" results through junit2html, junit-viewer or allure reports at this time seem like something that is not done all that much, due to the near non-existent material that I can gather. Is this pretty much uncharted territory or do I need to lower my expectations? 😄

flowthing 2020-07-14T10:55:56.067700Z

What’s the problem you’re having?

flowthing 2020-07-14T10:58:37.067900Z

I’ve previously used a Leiningen plugin (I think it was https://github.com/redbadger/test-report-junit-xml, but it might’ve been something else) to produce a jUnit XML report out of a Clojure test run. I’d imagine you could just pipe those XML documents into your jUnit XML -> HTML report generator of choice, but I have zero experience with that sort of thing, so I might be wrong.

johanmynhardt 2020-07-14T11:05:07.068300Z

I think my problem is inexperience TBH. By using defaults in all situations there is not a lot of information ending up in the output XML, with the result that the pretty reports I'm trying to get doesn't look like much. For example, having a look at what junit-viewer is capable of generating, it looks pretty good, but my generated XML does not result in the same awesomeness. I'm struggling to find exactly what I need to tweak to get more out, into the XML.

johanmynhardt 2020-07-14T11:08:06.068500Z

I've come across redbadger several times now but skipped it. So far I've tried standard clojure.test.junit and eftest . I get the same results, which points to my previous suspicion of having to dig deeper to understand reporting/report generation from Clojure better.

flowthing 2020-07-14T11:09:41.068700Z

Ah, right — I forgot about clojure.test.junit. Yeah, I have no experience there, I’m afraid.

johanmynhardt 2020-07-14T11:17:54.068900Z

Alright 😄 I'll 🤞 and dig around a bit more. I really dread to go redo this in Java 😰

plexus 2020-07-14T15:43:57.069100Z

FWIW Kaocha also has a junit XML plugin https://github.com/lambdaisland/kaocha-junit-xml feedback for this is very much welcome. The problem with junit.xml is that it's less of a standard than it seems, there are big differences in how tools interpret the results...

seancorfield 2020-07-14T15:44:53.069400Z

@johanmynhardt I don't think many Clojure folks bother with the jUnit XML stuff. What do you think you need that for?

seancorfield 2020-07-14T15:45:57.069600Z

(context: I've worked with Clojure in production for nine years and never needed to produce XML output from tests)

seancorfield 2020-07-14T15:48:38.069800Z

Also, what exactly do you mean by "end-to-end" tests? To me, that typically means driving the application using something like HtmlUnit or WebDriver...? We use HtmlUnit now but we used to clj-webdriver (no longer maintained).

johanmynhardt 2020-07-14T16:38:29.070Z

@seancorfield Thank you for your feedback, I will have a look at Kaocha too. I've done some digging around and found the XSD for xUnit/JUnit format, unofficial though - like you say, it's less of a standard. Well, the reason why I'm looking at JUnit report output is because it appears that most of the fancy dashboard/html-generation utilities out there handle it in some way or another. After looking at the XSD, there really isn't much to it, I just don't yet know how to get the attributes written to the file (like duration - everything is 0.0). So what I mean by end-to-end is close to what you have. I don't have it figured out yet... The existing legacy spaghetti-base did everything, or attempted, to do API and UI testing in one pass, using ExtentReports for screenshots and having quite verbose logging to System.out I've inherited a Java codebase where one of the largest files is a Java class of 8000 lines of code and no development principles to be mentioned. There are so many articles and definitions of the different levels and kinds of testing that it becomes a blur. I thought I knew enough about testing when I took on this project but I was wrong.

johanmynhardt 2020-07-14T16:40:07.070200Z

I feel like I'm rambling, I apologise. I'm just trying to grok testing in Clojure 😅 I have the basics down in writing the tests and I had several a-ha moments. I just didn't discover them all yet.

seancorfield 2020-07-14T16:42:27.070500Z

Sounds like quite the nightmare project -- good luck! 🙂 I hadn't thought about dashboards but, yeah, that makes sense.

seancorfield 2020-07-14T16:43:45.070700Z

I remembered after posting this that I did, at one point in the distant past, actually try to go down the XML generation route for some piece of a project we had at work... and I don't believe the supposedly jUnit-compatible viewer that we used understood the XML output from clojure.test.junit... but my memory is a bit hazy.

seancorfield 2020-07-14T16:44:15.070900Z

There's also "tap" output I believe, so maybe that format would work better with your dashboard tools?

johanmynhardt 2020-07-14T16:48:56.071100Z

I'll definitely have a look, thank you. The more I read about clojure.test and the other tools that hook into it, the more I sense that all the dots are there, I just need to connect them.

johanmynhardt 2020-07-14T16:57:06.071300Z

Kaocha is intriguing!

johanmynhardt 2020-07-14T16:58:33.071500Z

Anyway, I'm done for the day, need to recharge my mind. Thanks for the help!