android


Added JUnit, but Android Studio wants me to add testng


Referring to https://developer.android.com/training/testing/unit-testing/local-unit-tests.html and https://medium.com/#ali.muzaffar/the-basics-of-unit-and-instrumentation-testing-on-android-7f3790e77bd, I added
testCompile 'junit:junit:4.12'
in my gradle. Then I created a new test class, but apparently
#Test
throws 'Cannot resolve symbol'. On pressing ALT + Enter, Android Studio suggested me to 'Add testng to classpath'.
I don't quite understand what's going on here. I thought I don't need testng for what I'm trying to do here, nor the 2 articles above also didn't mention anything about testng.
Furthermore if I followed the Android Studio suggestion to 'Add testng to classpath', Android Studio will automatically add
androidTestCompile 'org.testng:testng:6.9.6'
in my gradle. And when I try to run the test, I will get the error
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lorg/hamcrest/Description;
Apparently changing
testCompile 'junit:junit:4.12'
to
androidTestCompile 'junit:junit:4.12'
solves this. Android Studio also won't bug me to add testng to classpath.
This Confused about testCompile and androidTestCompile in Android Gradle also helped me to understand more about testCompile vs androidTestCompile

Related Links

Android 4.1.2 bug: starting new Intent inside onActivityResult()
Android:Can I have diff versions of my app for various versions of devices
Android using fragments
Unsure if my Android app is sending valid POST requests
How to capture photo automatically in android phone? 0
How to implement phonegap/cordova in android webview?
click button open application if installed otherwise open play store in android?
FLAG_SHOW_WHEN_LOCKED not working in latest version of 4.4.2
Android Studio Update stuck cleaning up?
how to debug getSkuDetails when getting developer error 5
Cant access outer tabhost from an inner tabhost
Cloud synced notifications in Android L preview
Snapshot not working in google play game service [closed]
2 sliding menu with differrent size
ArrayIndexOutOfBoundException
Chromecast wont play Shoutcast Stream

Categories

HOME
notepad++
cygwin
porting
developer-tools
ng-idle
dns
gpu
formal-languages
angular-formly
youtube-data-api-v3
error-handling
can
spring-data-mongodb
cq5
nuget-package
jtextpane
pkcs#11
arangodb
resultset
opengl-es-3.0
naivebayes
zerobrane
internationalization
swagger-2.0
spring-async
babel
href
backpack-for-laravel
r-mice
itunes
bulletphysics
delimiter
intersystems-cache
tizen-tv
weather
spring-security4
papaparse
reverse
python-pptx
metawidget
google-data-api
opensmpp
tasm
vmware-fusion
datacachefactory
importerror
wc
apache-directory
dapper-simplecrud
vaadin-elements
textsum
openal
magento-2.0.7
carrot2
aquamacs
compiler-design
jqchart
er-diagram
mouseleave
cpu-cache
vcloud-director-rest-api
hadoop-2.7.2
mta
relativelayout
decimalformat
android-launcher
dronekit-android
telepat
typeconverter
uvc
public-html
at-job
appserver
dct
buffering
radiant
hibernate-entitymanager
kendo-dataviz
printdialog
inappsettingskit
tlf
gpars
superscrollorama
iboutlet
cuda-gdb
inkcanvas
virtualpathprovider
luabind
node-redis
tournament
umra
strsep
massive
photolibrary
object-database
build-environment
complex-event-processing
technical-debt
business-model
mathematical-typesetting
pnrp

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App