Commit c4397f64 authored by P P's avatar P P
Browse files

Merge remote-tracking branch 'origin/top-secret' into top-secret

parents 323a49ef e99c8644
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -4,6 +4,9 @@ plugins {
}

android {
    /*testOptions {
        unitTests.returnDefaultValues = true
    }*/
    namespace 'com.example.game2d'
    compileSdk 33

@@ -36,8 +39,25 @@ dependencies {
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'com.google.firebase:firebase-database:20.0.4'
    testImplementation 'junit:junit:4.13.2'
    testImplementation 'org.junit.jupiter:junit-jupiter'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    testImplementation "androidx.arch.core:core-testing:2.2.0"

    // testing
    allprojects {
        repositories {
            jcenter()
            google()
        }
    }
    // https://mvnrepository.com/artifact/org.mockito/mockito-core
    testImplementation group: 'org.mockito', name: 'mockito-core', version: '4.0.0'
    testImplementation 'org.mockito:mockito-inline:4.0.0'
    testImplementation 'org.mockito:mockito-junit-jupiter:4.0.0'
    // required if you want to use Mockito for Android tests
    testImplementation 'org.mockito:mockito-android:4.0.0'


    //*
    implementation platform('com.google.firebase:firebase-bom:31.5.0')
+40 −2
Original line number Diff line number Diff line
package com.example.game2d;

import org.junit.Rule;
import org.junit.Test;

import static org.junit.Assert.*;
//
import android.content.Context;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.when;


import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import androidx.arch.core.executor.testing.InstantTaskExecutorRule;

/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */

//@ExtendWith(MockitoExtension.class)
@RunWith(MockitoJUnitRunner.class)
public class ExampleUnitTest {
    @Test
    @Mock
    ChalkActivity testObj;

     /*@Test
    public void addition_isCorrect() {
        assertEquals(4, 2 + 2);
    }*/


    // -------------------------------- BEGIN --------------------------------
    // ChalkActivity.java
    @Test
    public void randomizeOrderTest() {
        int[] original = new int[] { 0, 1, 2, 3 };
        ChalkActivity testObj = new ChalkActivity();
        int[] created = testObj.randomizeOrders();
        for (int i = 0; i < 4; i++) {
            System.out.println(created[i]);
        }
        assertEquals(original, testObj.randomizeOrders());
    }


}
 No newline at end of file