This assignment will help you practice using the command line.
Do all of the following in the terminal:
Fork this repository into your own Github account:
Open Terminal and navigate to your projects directory.
Clone the forked repository to your projects directory. This should create a new directory in your projects directory named tiy-homework-command-line-practice
.
Confirm that the tiy-homework-command-line-practice
directory exists and navigate into it.
The project you cloned uses a tool called Gradle that you haven't been introduced to yet. We can use Gradle to test run and test this project at any time. Go ahead and test the project by running gradle test --info
. You should see the output similar to this:
$ gradle test --info
Starting Build
Settings evaluated using settings file '/Users/doug/Scratch/tiy-homework-command-line-practice/settings.gradle'.
Projects loaded. Root project using build file '/Users/doug/Scratch/tiy-homework-command-line-practice/build.gradle'.
Included projects: [root project 'commandLinePractice']
Evaluating root project 'commandLinePractice' using build file '/Users/doug/Scratch/tiy-homework-command-line-practice/build.gradle'.
All projects evaluated.
Selected primary task 'test' from project :
Tasks to be executed: [task ':compileJava', task ':processResources', task ':classes', task ':compileTestJava', task ':processTestResources', task ':testClasses', task ':test']
:compileJava (Thread[main,5,main]) started.
:compileJava
Skipping task ':compileJava' as it has no source files.
:compileJava UP-TO-DATE
:compileJava (Thread[main,5,main]) completed. Took 0.048 secs.
:processResources (Thread[main,5,main]) started.
:processResources
Skipping task ':processResources' as it is up-to-date (took 0.066 secs).
:processResources UP-TO-DATE
:processResources (Thread[main,5,main]) completed. Took 0.073 secs.
:classes (Thread[main,5,main]) started.
:classes
Skipping task ':classes' as it has no actions.
:classes UP-TO-DATE
:classes (Thread[main,5,main]) completed. Took 0.001 secs.
:compileTestJava (Thread[main,5,main]) started.
:compileTestJava
Skipping task ':compileTestJava' as it is up-to-date (took 0.425 secs).
:compileTestJava UP-TO-DATE
:compileTestJava (Thread[main,5,main]) completed. Took 0.442 secs.
:processTestResources (Thread[main,5,main]) started.
:processTestResources
Skipping task ':processTestResources' as it has no source files.
:processTestResources UP-TO-DATE
:processTestResources (Thread[main,5,main]) completed. Took 0.001 secs.
:testClasses (Thread[main,5,main]) started.
:testClasses
Skipping task ':testClasses' as it has no actions.
:testClasses UP-TO-DATE
:testClasses (Thread[main,5,main]) completed. Took 0.003 secs.
:test (Thread[main,5,main]) started.
:test
Executing task ':test' (up-to-date check took 0.057 secs) due to:
No history is available.
Starting process 'Gradle Test Executor 1'. Working directory: /Users/doug/Scratch/tiy-homework-command-line-practice Command: /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/bin/java -Djava.security.manager=jarjar.org.gradle.process.internal.child.BootstrapSecurityManager -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -ea -cp /Users/doug/.gradle/caches/2.11/workerMain/gradle-worker.jar jarjar.org.gradle.process.internal.launcher.GradleWorkerMain 'Gradle Test Executor 1'
Successfully started process 'Gradle Test Executor 1'
Gradle Test Executor 1 started executing tests.
Gradle Test Executor 1 finished executing tests.
CommandLineTest > deleteMeTxtIsDeletedTest FAILED
java.lang.AssertionError: src/main/resources/deleteMe.txt is not deleted
Expected: is
but: was
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at CommandLineTest.deleteMeTxtIsDeletedTest(CommandLineTest.java:57)
CommandLineTest > imageFolderIsAFolderTest FAILED
java.lang.AssertionError: src/main/resources/images folder is not a folder
Expected: is
but: was
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at CommandLineTest.imageFolderIsAFolderTest(CommandLineTest.java:36)
CommandLineTest > fruitContainsCorrectTextTest FAILED
java.nio.file.NoSuchFileException: fruit.txt
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
at java.nio.file.Files.newByteChannel(Files.java:361)
at java.nio.file.Files.newByteChannel(Files.java:407)
at java.nio.file.Files.readAllBytes(Files.java:3152)
at CommandLineTest.fruitContainsCorrectTextTest(CommandLineTest.java:79)
CommandLineTest > exampleFolderDeletedTest FAILED
java.lang.AssertionError: example folder is not deleted
Expected: is
but: was
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at CommandLineTest.exampleFolderDeletedTest(CommandLineTest.java:64)
CommandLineTest > misspellllledTxtRenamedTest FAILED
java.lang.AssertionError: misspellllled.txt not renamed to misspelled.txt
Expected: is
but: was
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at CommandLineTest.misspellllledTxtRenamedTest(CommandLineTest.java:86)
CommandLineTest > renameMainTest FAILED
java.lang.AssertionError: Didn't rename Main.java to Main.java
Expected: is
but: was
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at CommandLineTest.renameMainTest(CommandLineTest.java:15)
CommandLineTest > tiyLogoInImagesFolderTest FAILED
java.lang.AssertionError: the-iron-yard-logo.png is not in the src/main/resources/images
Expected: is
but: was
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at CommandLineTest.tiyLogoInImagesFolderTest(CommandLineTest.java:43)
CommandLineTest > mainWasRunTest FAILED
java.lang.AssertionError: Didn't run 'gradle -run'
Expected: is
but: was
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at CommandLineTest.mainWasRunTest(CommandLineTest.java:22)
CommandLineTest > fruitTxtExistsTest FAILED
java.lang.AssertionError: fruit.txt does not exist
Expected: is
but: was
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at CommandLineTest.fruitTxtExistsTest(CommandLineTest.java:71)
CommandLineTest > imageFolderCreatedTest FAILED
java.lang.AssertionError: Images folder was not created
Expected: is
but: was
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at CommandLineTest.imageFolderCreatedTest(CommandLineTest.java:29)
CommandLineTest > tiyLogoNotInRoot FAILED
java.lang.AssertionError: the-iron-yard-logo.png is not in the src/main/resources/images
Expected: is
but: was
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at CommandLineTest.tiyLogoNotInRoot(CommandLineTest.java:50)
11 tests completed, 11 failed
Finished generating test XML results (0.034 secs) into: /Users/doug/Scratch/tiy-homework-command-line-practice/build/test-results
Generating HTML test report...
Finished generating test html results (0.034 secs) into: /Users/doug/Scratch/tiy-homework-command-line-practice/build/reports/tests
:test FAILED
:test (Thread[main,5,main]) completed. Took 1.598 secs.
FAILURE: Build failed with an exception.
- What went wrong:
Execution failed for task ':test'.There were failing tests. See the report at: file:///Users/doug/Scratch/tiy-homework-command-line-practice/build/reports/tests/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
BUILD FAILED
Total time: 5.828 secs
Stopped 0 compiler daemon(s).
This output shows us that 11 tests were run, but all 11 failed. You can rerun the tests as often as you would like while you work through the homework. You have completed the homework successfully when all tests pass. Follow these instructions to make the tests pass:
-
There is a file named
main.txt
in the foldersrc/main/java/
. This file must be renamed toMain.java
. -
Now that you've correctly renamed the Main.java file you can to run it using
gradle run -q
in the root directory of the project. This will print out a friendly message and create a new file namedmainWasRun.txt
in the root of your project. -
Create a new folder named
images
in the foldersrc/main/resources
. -
There is a file in the root of the project named
the-iron-yard-logo.png
. This must be moved into theimages
folder you just created insrc/main/resources
. -
There is a file named
deleteMe.txt
in thesrc/main/resources
folder. This must be deleted. -
There is a folder named
example
in the root of the project. This must be deleted. -
Create a new file in the root of the project named
fruit.txt
. Using the command line, put the following text into the file:apples, oranges, hot dogs, grapes, peaches
-
There is a file named
misspellllled.txt
in the root of the project. Rename it tomisspelled.txt
.
Once all of the tests are passing use Git to commit the changes you made and push them to your Github repository.
Finally, submit the SSH url of your repository as the submission for this assignment.