Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression #4

Open
wants to merge 88 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
2d29dc7
Update gradle build with newer target Sdk Version and updated impleme…
Carrie0302 Apr 26, 2020
52bf3c8
First commit, updated AS and plugins
laurakelarson Apr 26, 2020
899f4c5
Tests for the QuestionScoreTest getters and setters
Carrie0302 Apr 27, 2020
0801408
Added MockParcel inorder to test Parcelable classes that are used to …
Carrie0302 Apr 27, 2020
4581ca4
Added testing for the parcelable QuestionScorerTest thats used to con…
Carrie0302 Apr 27, 2020
151eeae
Add new test class for IndividualQuestion
Carrie0302 Apr 27, 2020
25c6ad0
Added categories test to IndividualQuestion unit tests
Carrie0302 Apr 27, 2020
a7f599b
Write to parcel then create Individual Question from Parcel
Carrie0302 Apr 27, 2020
3970392
Test reading from the array of parcelable objects in IndividualQuesti…
Carrie0302 Apr 27, 2020
c71368e
Added category does not exist test to check that exception is thrown …
Carrie0302 Apr 27, 2020
9fbe4bf
Merge pull request #2 from Carrie0302/IndividualQuestionTest
Carrie0302 Apr 27, 2020
4ef213d
Added acknowledgment test folder and created acknowledgment object te…
laurakelarson Apr 27, 2020
be25f56
Added test classes for Acknowledgements
laurakelarson Apr 27, 2020
dd505a2
Update .gitignore
laurakelarson Apr 27, 2020
322e5e9
Add a unit test for getNumberOfPerfectQuizzes to check for null first…
lmirzaei Apr 27, 2020
e00104f
Add a unit test for getNumberOfPerfectQuizzes to check for null secon…
lmirzaei Apr 27, 2020
c4d4811
Add a unit test for getNumberOfPerfectQuizzes to check for scorelist …
lmirzaei Apr 27, 2020
243aa3a
Add a unit test for getNumberOfPerfectQuizzes to check for scorelist …
lmirzaei Apr 27, 2020
4991113
Added setup to AcknowledgementObjectTest
laurakelarson Apr 27, 2020
831b493
Added tests for GetName and GetLink in AcknowledgementObjectTest
laurakelarson Apr 27, 2020
b0341b8
Added code to test method AcknowledgementObject_GetNameTest()
laurakelarson Apr 27, 2020
b393054
Fix .giignore and .idea issues
Carrie0302 Apr 27, 2020
f77aadf
Trying to solve uri.parse() method issue with testing
laurakelarson Apr 27, 2020
57c72b8
Merge branch 'laurabranch' of https://github.com/Carrie0302/TrivialTr…
laurakelarson Apr 27, 2020
a4b0787
Update .gitignore
Carrie0302 Apr 27, 2020
5157998
Merge branch 'master' into laurabranch2
Carrie0302 Apr 27, 2020
337cada
Merge branch 'master' into laurabranch2
Carrie0302 Apr 27, 2020
1dd286f
Merge branch 'laurabranch2'
Carrie0302 Apr 27, 2020
8b74ed2
Fix androidTest folder by adding the correct dependencies in the grad…
Carrie0302 Apr 29, 2020
26c8b87
Added UT AcknowledgementObject_GetLinkTest()
laurakelarson Apr 30, 2020
0884773
Added skeleton tests to AcknowledgementStorage UT
laurakelarson Apr 30, 2020
afe3e2d
Added UT AcknowledgementStorage_getQuestionsAcknowledgmentObjectsTest()
laurakelarson Apr 30, 2020
26af6db
Added UT AcknowledgementStorage_getImagesAcknowledgmentObjectsTest()
laurakelarson Apr 30, 2020
b2d0b8f
Merge pull request #4 from Carrie0302/AcknowledgementsTests
laurakelarson Apr 30, 2020
4462ee9
Merge pull request #5 from Carrie0302/QuizScorerTest
Carrie0302 May 1, 2020
1a767fc
Add six unit tests for OverallStatisticsCalculator.getOverallPerforma…
lmirzaei May 1, 2020
e141091
Merge pull request #6 from Carrie0302/lmirzaei/category-statistics-ca…
Carrie0302 May 1, 2020
b548047
Update README with instructions
Carrie0302 May 4, 2020
e9a2e8d
Update README.md
Carrie0302 May 4, 2020
1624511
Use Mockito to pass Context to the QuizScorer and Set size unit test …
Carrie0302 May 4, 2020
da16ba5
Test for negatives, you should not set a negative number of questions…
Carrie0302 May 4, 2020
906e092
Fix for testing static factory in quizscorer
Carrie0302 May 4, 2020
9fe4be6
Test Can not check the score of a quiz before quiz completion
Carrie0302 May 4, 2020
1930945
Test scores are correct with one question quiz with wrong answer sele…
Carrie0302 May 4, 2020
cae8452
Remove unused setQuestionScorers and add message annotations to tests
Carrie0302 May 8, 2020
a914d44
Test average times of taking the quiz and compare using the maximum d…
Carrie0302 May 8, 2020
7e6d01f
Test qiuz score should not take null array list and remove unused met…
Carrie0302 May 8, 2020
f98d5de
Get the category score report and test to see if it has the appropria…
Carrie0302 May 8, 2020
c390f45
Test the report of the times by category per quiz
Carrie0302 May 8, 2020
c3513e6
Add tests for average time spent on correct and wrong answers
Carrie0302 May 8, 2020
68a6cca
Add test for all category record content values in QuizScorer
Carrie0302 May 8, 2020
c8a8110
Merge pull request #7 from Carrie0302/TestQuizScorer
Carrie0302 May 9, 2020
5a6f8a4
Fix Coverage Report, switch to Jacoco which plays nice with Roboelect…
Carrie0302 May 15, 2020
3b89af4
Add Insert Record Service Test
Carrie0302 May 18, 2020
c049b9e
Fix linter error in activity
Carrie0302 May 18, 2020
e726158
Add service account credentials for possible CICD pipeline
Carrie0302 May 18, 2020
a59cb3d
Move Insert Record Service Test to the Correct Folder for testing
Carrie0302 May 18, 2020
db285b0
Add QuizDBContract test for building URI on the quiz id
Carrie0302 May 18, 2020
ecf4c46
Test the DBContract for the category name and the category id
Carrie0302 May 18, 2020
5f4c673
Test the URI of the category index and the category total questions a…
Carrie0302 May 18, 2020
e710dd3
Add test for the return URI from teh Quiz Score for ID
Carrie0302 May 18, 2020
f6bfca6
Fix bug with code coverage being zero percent when running all tests …
lmirzaei May 19, 2020
afffb73
Test the QuizDBHelper class and check that the initial category conte…
Carrie0302 May 21, 2020
ff70e89
Initial count of database categories test
Carrie0302 May 21, 2020
219c2dc
Test getting the readable database from the QUizDBHelper
Carrie0302 May 21, 2020
6d87a52
Add new category into DB test
Carrie0302 May 21, 2020
cb8891c
Test downgrade function on QuizDBHelper
Carrie0302 May 21, 2020
180b5d3
Merge remote-tracking branch 'origin/master' into InsertRecordService…
Carrie0302 May 21, 2020
e5f60c7
Fix order of actual and expected.
lmirzaei May 23, 2020
5087138
Add unit tests for CategoryStatisticsCalculator class.
lmirzaei May 23, 2020
262d7c1
Merge pull request #9 from Carrie0302/lmirzaei/category-statistics-ca…
Carrie0302 May 23, 2020
22c7c2b
Add regression tests
Carrie0302 May 25, 2020
8d422d3
Add gitignore for config
Carrie0302 May 30, 2020
64cabee
Add logging in build.gradle so that it shows the tests run in the com…
Carrie0302 May 30, 2020
f1de20c
Initial regression test file that calls android unit tests
Carrie0302 May 30, 2020
1d7431c
Update the gradle process to run the build before each test run
Carrie0302 May 30, 2020
f08e373
Format output from the regression tests
Carrie0302 May 30, 2020
766245c
Check for failures and format the output of the test failures for the…
Carrie0302 May 30, 2020
0a45ad1
Add the possibility to email the results
Carrie0302 May 30, 2020
532eb09
Add average run time to regression report
Carrie0302 May 30, 2020
fbb06ff
Merge pull request #10 from Carrie0302/Regression
Carrie0302 May 30, 2020
a94c559
Make RunTestSuite.py executable
lmirzaei May 31, 2020
6b339af
Use gradle wrapper instead of depending on system's gradle version
lmirzaei May 31, 2020
a27be5a
Add __pycache__/ to gitignore
lmirzaei May 31, 2020
1ad8e4c
Remove clean from RunTestSuite
lmirzaei May 31, 2020
c721dc7
Add a shell script for stress testing
lmirzaei May 25, 2020
e024eae
Merge pull request #11 from Carrie0302/lmirzaei/stress-test-script
Carrie0302 Jun 1, 2020
7071806
Fix error in the gradle call
Carrie0302 Jun 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@
/build
/captures
.externalNativeBuild
.idea
modified-key-92e6.json
config.py
__pycache__/
22 changes: 0 additions & 22 deletions .idea/compiler.xml

This file was deleted.

3 changes: 0 additions & 3 deletions .idea/copyright/profiles_settings.xml

This file was deleted.

3 changes: 0 additions & 3 deletions .idea/dictionaries/avinashdavid.xml

This file was deleted.

19 changes: 0 additions & 19 deletions .idea/gradle.xml

This file was deleted.

77 changes: 0 additions & 77 deletions .idea/misc.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/modules.xml

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@

# TrivialTrivia
Remake of "trivial trivia" with native Android code and a truer implementation of Model-View-Presenter paradigm.

## Installation
Import into Android Studio, build and run. Alternatively, install the last stable version from the [Play Store](https://play.google.com/store/apps/details?id=com.avinashdavid.trivialtrivia)
## Setup Instructions

* Install Android Studio 3.6 or later

* Clone the repository. In terminal or command prompt: git clone https://github.com/Carrie0302/TrivialTrivia.git
* In Android Studio, click “Open an existing Android Studio project”
* Navigate to the root of the cloned git repository
* Wait for Gradle Sync to sync the project and download dependencies

## Running the Unit Tests

* Navigate to the test class to be run (ex. OverallStatisticsCalculatorTest)

* Click the green play button next to the test class or individual test method and select “Run with Coverage” to get code coverage metrics

## Description
This is a remake of my first published app, which was called "Trivial Trivia". On the Play Store, this version of the app can be found under the name "Trivial Trivia 2".
Expand Down
139 changes: 139 additions & 0 deletions RunTestSuite.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#!/usr/bin/env python3

import subprocess, smtplib, ssl, sys, time
from email.message import EmailMessage
import re, config
import random, datetime


"""
RunTestSuite runs the unit tests in android studio a certain
number of times and emails the results using gradle commands.

Example of running this script:
$ python RunTestSuite.py 2 [email protected]
"""

def generateSummary(testResults, timeStart, timeEnd, i ):
elapsedTime = timeEnd - timeStart
outcome = "\nLoop " + str(i) + ": " + testResults +" Elapsed Time: " + str(round(elapsedTime, 2)) + "s\n"
return outcome


def getTestResults(output):
if "BUILD SUCCESSFUL" not in str(output):
testResults = "\033[1;31;40m FAILED \x1b[0m"
result = "Some Tests Failed "
else:
testResults = "\033[1;32;40m PASSED \x1b[0m"
result = "All Tests Pass "
return result


def runAndroidTest():
subprocess.call("gradlew build -x lint", shell=True)
cmdExe = "gradlew test"
process = subprocess.Popen(cmdExe, stdout=subprocess.PIPE, shell=True)
output = process.communicate()[0]
output = str(output)
return output

def createEmail(testResults, resultFormat, fails, total ):
#version = random.randint(0, 500)
today = datetime.datetime.now()
email = "Subject: Trivial Trivia Test Summary - " + testResults + today.strftime("%x") + " \n"
email += total + resultFormat + fails
return email


def formatLoopOutput(loopNum, outputOrig, verbose):
countPass = 0
countFail = 0
output = outputOrig.replace('\\n', '\n')

allP = re.findall("PASSED", output)
for p in allP:
countPass+=1
allFails = re.findall("com.avinashdavid.trivialtrivia.*FAILED", output)
fails = set(allFails)
for f in allFails:
countFail+=1

totalUnitTests = countPass + countFail
result = " UNIT TESTS: Passed = " + str(countPass) + " Failed = " + str(countFail) + " - Loop " + str(loopNum) + "\n"
if verbose:
print(output)
summary = ""
allS = re.findall("RUNNING.*result: SUCCESS", output)
for s in allS:
summary += s + "\n"
return summary + result
return (result, fails, countPass, totalUnitTests)


def runTestMultipleTimes( numLoop ):
overallResult = ""
avgTimeAndRuns = ""
totalTime = 0
for i in range(numLoop):
timeStart = time.time()
output = runAndroidTest()
resultFormat, fails, countPass, totalUnitTests = formatLoopOutput( i, output , False )
timeEnd = time.time()
testResults = getTestResults( output )
overallResult += "\n" + generateSummary(testResults, timeStart, timeEnd, i)
overallResult += resultFormat
avgTimeAndRuns = "\nIn Test Suite - Unit Tests (Passed {0} of {1})".format(countPass, totalUnitTests)
totalTime += (timeEnd - timeStart)
avgTime = totalTime / (i + 1)
avgTimeAndRuns += "\nThe Entire Suite was Run {0} times - Avg Time {1:.2f}".format( str(i+1), avgTime )
return [testResults, overallResult, fails, avgTimeAndRuns]


def formatFailure( fails ):
results = "\nFailures: \n"
uniqueFail = set()
for f in fails:
if f not in uniqueFail:
uniqueFail.add( f )
results += " " + f + "\n"
return results


if __name__ == "__main__":
"""
Can take up to 2 Command Line Arguments, the number of times to run the entire
suite of tests from android and the email the report should be sent to.
"""

if(len(sys.argv) == 3):
numLoop = int(sys.argv[1])
receiver_email = sys.argv[2]
sendEmail = True
elif(len(sys.argv) == 2):
numLoop = int(sys.argv[1])
sendEmail = False
else:
numLoop = 1
sendEmail = False

print( "\nTEST SUMMARY:\n")
testResults, overallResult, fails, avgTimeAndRuns = runTestMultipleTimes(numLoop)
uniqueFail = formatFailure( fails )
print( avgTimeAndRuns )
print( overallResult )
print( uniqueFail )

if sendEmail:
port = 465 # For SSL
smtp_server = "smtp.gmail.com"
sender_email = config.sender
password = config.password

email = createEmail(testResults, overallResult, uniqueFail, avgTimeAndRuns)
context = ssl.create_default_context()

with smtplib.SMTP_SSL(smtp_server, port, context=context) as server:
server.login(sender_email, password)
server.sendmail(sender_email, receiver_email, email)
server.quit()
43 changes: 43 additions & 0 deletions StressTestApp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/zsh
trap "exit" INT TERM
trap "kill 0" EXIT

if [ "$#" -ne 2 ]; then
echo "Usage: StressTestApp.sh <number of iterations> <number of background processes>"
exit -1
fi

NUM_ITERATIONS=$1
NUM_BACKGROUND_PROCESSES=$2

# Run once before to do any necessary compilation once
echo "Pre-compiling tests"
./RunTestSuite.py 1 > /dev/null 2>&1
START_TIME=$(date)
START_SECONDS=$SECONDS

PID_ARRAY=()
for ((i=0;i<$NUM_BACKGROUND_PROCESSES;i++))
do
./RunTestSuite.py $NUM_ITERATIONS > /dev/null 2>&1 &
PID_ARRAY+=($!)
echo "Started background process $((i+1)) with PID $!"
done

echo "Created ${#PID_ARRAY[@]} background processes"
for PID in "${PID_ARRAY[@]}"
do
echo "Waiting for background process with ID $PID"
wait $PID
done

COMPLETED_TIME=$(date)
ELAPSED_SECONDS=$(($SECONDS - $START_SECONDS))

echo "
Finished executing stress test with parameters:
Number of background processes: $NUM_BACKGROUND_PROCESSES
Number of iterations: $NUM_ITERATIONS
Start time: $START_TIME
End time: $COMPLETED_TIME
Elapsed seconds: $ELAPSED_SECONDS"
Loading