Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Java Project 1: Provided tests not loading.

Hello Everyone. The tests that are provided with the first Java Project "How many in a Jar" do not seem to be working for me anymore. The libraries downloaded, but the script that gets compiled into the cache gets killed every single time. Here is the console output:

treehouse:~/workspace$ ./gradlew test
Downloading https://services.gradle.org/distributions/gradle-2.5-all.zip
......................................................................................................

Unzipping /home/treehouse/.gradle/wrapper/dists/gradle-2.5-all/d3xh0kipe7wr2bvnx5sk0hao8/gradle-2.5-al /home/treehouse/.gradle/wrapper/dists/gradle-2.5-all/d3xh0kipe7wr2bvnx5sk0hao8
Set executable permissions for: /home/treehouse/.gradle/wrapper/dists/gradle-2.5-all/d3xh0kipe7wr2bvnx gradle-2.5/bin/gradle
Killed
treehouse:~/workspace$ ./gradlew test
Loading > Compiling script into cacheKilled

The tests worked yesterday, but since the server maintenance my project got reset. So I just decided to start over for more practice, but now I cannot get the tests to load at all.

Does anyone have any suggestions?

3 Answers

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Hi Alen Sabic !

Sorry just saw this. :/

Can you do me a favor and try taking a snapshot and then forking your workspace. It seems like your current workspace is locked with the old memory settings.

Let me know if that works, and sorry for not seeing your reply until now!

Craig

No worries Craig.

I have tried your suggestion.

I have to run the command a few times(usually 3-5 times), but once the tests compile once successfully I'm able to run them fine. Not really sure why the tests won't compile and run on the first go.

On a related note I'm a little confused on how the tests handle input validation. Even though I prevent the user from entering numbers <= 0 and numbers greater than the max amount, I still end up failing those tests even though they work in my program. I have my Jar.java handle all the game mechanics, while my Prompter.java handles all the input and validation, as well as the start up of the game.

Craig Dennis
Craig Dennis
Treehouse Teacher

Can you share your workspace with me? craig [at] teamtreehouse.com

Hi Craig.

Just wanted to check if I got my email that I sent yesterday with my workspace linked.

Hopefully I did it correctly.

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Hey Alen,

Tests should be working now. Thanks for reporting this, we got more memory allotted for our Java workspaces!

Hey Craig.

I'm still having issues. Here is the console output.

treehouse:~/workspace$ ./gradlew test
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':test'.
    Process 'Gradle Test Executor 1' finished with non-zero exit value 137

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 20.184 secs

Occasionally it completes one test before this happens:

Building 85% > :test > 1 test completedKilled

I'll let you know if I get any other error messages.

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Good news Alen Sabic !

Looks like it is indeed working now. Those test failures that are happening now are indeed failures. Try just adding 1 to your random number ;)

Everything else is looking great!

Sorry about the problems, it was taking more than our servers allocated and getting killed. We finally narrowed down the problem!

Thank you Graig. The tests are compiling fine now.

Are you sure that my random number generator is at fault for the failing tests?

I ran my random number generator through a for loop with a 1000 iterations

For example, after I add 1 to my random number generator as was suggested:

If I ask the user for a number between 1 and 5, my random number generator will generate a random number between 2 and 6.

My original number generator where 1 is not added to my random number gives me the correct output of a number between 1 and 5.