Creos
Creos

Reputation: 2525

How to Unit Test Google Cloud Endpoints Java Using Android Studio 0.8

I've found a few posts, but they either refer to front-end testing, or python. There is one tutorial for java GCE but there's no specificity on how to set it up in Android Studio, just a few random references to Eclipse.

eg

Unit tests in Android Studio 0.8

https://developers.google.com/appengine/docs/java/tools/localunittesting#Java_Writing_Datastore_and_memcache_tests

https://www.youtube.com/watch?v=z47B1nhC3K0

Feel free to yell at me if I've missed some relevant post and direct me to it. Thank you.


Rant: please ignore. May I say I find it insane that in 2014, on their brand new Android Studio (IntelliJ) platform, with all the lessons learned from previous iterations, Google has failed to provide a simple, seamless way to set up front-/back-end testing? I cannot decide what epithet to use here: pathetic, horrendously lacking any foresight, or lazy? Yes, I know name calling is not productive, but I feel I have the right to be outraged. I know Google wants its developers to be successful, so why is it not utterly and completely obvious that any kind of IDE solution must include at least a basic workflow baked in to do testing. Get on it Google! Testing is not an after-thought. It's the CORE of having any kind of non-trivial code out there in production. Fix this. We shouldn't need the community to come up with a patch-work of random solutions that stop working every few months. Google is a software company, they know this stuff. I love you Google but in this instance I'm disgusted and you know we all are right to be. /rant

Upvotes: 4

Views: 719

Answers (1)

Creos
Creos

Reputation: 2525

Ok with some gradle googling, I managed to get it to work by adding the following the the build.gradle file in my backend module

testCompile 'com.google.appengine:appengine-api-labs:1.9.8'
testCompile 'com.google.appengine:appengine-api-stubs:1.9.8'
testCompile 'com.google.appengine:appengine-testing:1.9.8'
testCompile 'junit:junit:4.12+'

And also following this (in the original post) https://developers.google.com/appengine/docs/java/tools/localunittesting#Java_Writing_Datastore_and_memcache_tests

Hopefully it helps someone else as well.

Upvotes: 2

Related Questions