Unit testing options in GOSU?

749 views
Skip to first unread message

Geoff Caplan

unread,
Mar 2, 2018, 10:54:18 AM3/2/18
to gosu-lang
Hi folks

Tempted to give GOSU a spin, but cant find anything recent on testing. I'd want to run tests the standard way in IntelliJ, ideally with automatic test-file generation using Alt-RETURN.

Is there anything innovative and native in GOSU itself?

Failing that, would it be practical to set up Spock? (I use Gradle).

Failing that, how would I set up JUnit 5?

Can I gently suggest that this issue is covered more explicity in the gosu-lang docs? 

Thanks for any help.

Kyle Moore

unread,
Mar 2, 2018, 12:25:55 PM3/2/18
to gosu-lang
Hi Geoff.

Here is a simple example of a JUnit 4 test working with Gosu. Sorry but I'm not familiar with IJ's automatic test generation you speak of. I also haven't had a chance to try out JUnit 5 yet. I don't see why it wouldn't work, but you're welcome to be an early adopter :)

Regarding Spock, yes I'm familiar and I wrote most of our Gradle plugin tests for Gosu using Spock. However all those tests are in Groovy. I'm not sure how the dynamic given/when/then triples would work in a statically-typed language like Gosu or Java... if at all. In other words, you could use Spock + Groovy to test your Gosu classes. But unless you have a working example of a Java class extending Specification, then I doubt Gosu could work with that.

- Kyle

Geoff Caplan

unread,
Mar 2, 2018, 12:59:00 PM3/2/18
to gosu-lang
Kyle

Thanks for the quick reply.

Spock works fine with Java -  there are even a couple of books about it:

https://www.manning.com/books/java-testing-with-spock

I've got it working with my Java project in IntelliJ, but as I'm a total Gradle newbie, any tips that might lessen the pain of trying to get it working with GOSU would be very welcome, if you have a moment to spare.

As I said in my original post, offering some more explicit help with setting up testing in the Docs would surely help ease people more painlessly into adopting the language.

Very impressed with what I've seen, by the way - nice design.  Kotlin seems to have "borrowed" some of your ideas, but I think I prefer the simplicity of  GOSU. As you say - pragmatic with useful typing without the huge cognitive overhead of a Scala or a Frege. I suspect you get 70% of the payoff for 10% of the effort. For someone like me who doesn't programme full-time (I write code for my business, not as my business), a small language that you can keep in your head is a big advantage.

Not really clear why it hasn't had more traction in the Java community. You're offering nice tooling in IntelliJ, easy interop with Java and the backing of a substantial company that's fully committed to the language.

Developers seem to feel that you need complex languages to write complex programmes, while simpler solutions like GOSU or NetRexx are pretty much ignored.

Ah well...
- Geoff
Reply all
Reply to author
Forward
0 new messages