Leave a rating/review
Find the starter project for this application in the github repo for this episode and open it in Android Studio. Wait until gradle has finished syncing your project. Once that is done run your app on your emulator and you will see a blank screen. For now we are just going to minimize this. Stop your application.
And we’ll start writing our first tests. But to start writing our tests we will use JUnit so we need to add the appropiate dependencies.
Open your project navigator, under gradle, module and in here at the end we are going to add this line:
testImplementation 'junit:junit:4.13.2'
Press sync now and wait until gradle finishes syncing all your dependencies.
Notice that it is test implementation instead of implementation because you will only use these dependencies for testing purposes. These basically means that it wont be bundled in your applications apk that your device or emulator will run.
Also, when you create new android projects this line us usually added by default, we are only adding it here manually for educational purposes.
Well, gradle has finished syncing our dependencies. And we are going to write our first unit test. To do that we are going to create a new package. It is easier to do that using the project view. And under app source we are going to create a new directory. New, directory, and type all of this:
test/java/com/raywenderlich/android/cocktails/game/model
Enter, and inside the model package which is the last package create a new kotlin class file and we are going to name it GameUnitTests.
We are creating the GameUnitTests class because we are going to write tests for the first class of our cocktail game which is going to be named Game. As simple as that.