Documente Academic
Documente Profesional
Documente Cultură
Advertisements
PreviousPage NextPage
Dearreaders,theseJUnitInterviewQuestionshavebeendesignedspeciallytogetyou
acquainted with the nature of questions you may encounter during your interview for the
subjectofJUnit.Aspermyexperiencegoodinterviewershardlyplantoaskanyparticular
question during your interview, normally questions start with some basic concept of the
subjectandlatertheycontinuebasedonfurtherdiscussionandwhatyouanswer:
WhatisTesting?
Testingistheprocessofcheckingthefunctionalityoftheapplicationwhetheritisworkingas
perrequirements.
WhatisUnitTesting?
Unittestingisthetestingofsingleentity(classormethod).Unittestingisveryessentialto
everysoftwarecompanytogiveaqualityproducttotheircustomers.
WhatisManualtesting?
Executingthetestcasesmanuallywithoutanytoolsupportisknownasmanualtesting.
WhatisAutomatedtesting?
Taking tool support and executing the test cases by using automation tool is known as
automationtesting.
Whatarethedisadvantagesofmanualtesting?
Followingarethedisadvantagesofmanualtesting
TimeconsumingandtediousSincetestcasesareexecutedbyhumanresourcesso
itisveryslowandtedious.
HugeinvestmentinhumanresourcesAstestcasesneedtobeexecutedmanually
somoretestersarerequiredinmanualtesting.
Less reliable Manual testing is less reliable as tests may not be performed with
precisioneachtimebecauseofhumanerrors.
Whataretheadvantagesofautomatedtesting?
Followingaretheadvantagesofautomatedtesting
FastAutomationrunstestcasessignificantlyfasterthanhumanresources.
MorereliableAutomationtestsperformpreciselysameoperationeachtimethey
arerun.
WhatisJUnit?
WhatareimportantfeaturesofJUnit?
FollowingaretheimportantfeaturesofJUnit
Itisanopensourceframework.
ProvidesAnnotationtoidentifythetestmethods.
ProvidesAssertionsfortestingexpectedresults.
ProvidesTestrunnersforrunningtests.
JUnit tests can be run automatically and they check their own results and provide
immediatefeedback.
JUnit tests can be organized into test suites containing test cases and even other
testsuites.
JUnitshowstestprogressinabarthatisgreeniftestisgoingfineanditturnsred
whenatestfails.
WhatisaUnitTestCase?
A Unit Test Case is a part of code which ensures that the another part of code (method)
works as expected. To achieve those desired results quickly, test framework is required
.JUnitisperfectunittestframeworkforjavaprogramminglanguage.
WhatarethebestpracticestowriteaUnitTestCase?
Aformalwrittenunittestcaseischaracterizedbyaknowninputandbyanexpectedoutput,
whichisworkedoutbeforethetestisexecuted.Theknowninputshouldtestaprecondition
andtheexpectedoutputshouldtestapostcondition.
Theremustbeatleasttwounittestcasesforeachrequirement:onepositivetestandone
negative test. If a requirement has subrequirements, each subrequirement must have at
leasttwotestcasesaspositiveandnegative.
WhenareUnitTestswritteninDevelopmentCycle?
Testsarewrittenbeforethecodeduringdevelopmentinordertohelpcoderswritethebest
code.
WhynotjustuseSystem.out.println()fortesting?
Debugging the code using system.out.println() will lead to manual scanning of the whole
outputeverytimetheprogramisruntoensurethecodeisdoingtheexpectedoperations.
Moreover,inthelongrun,ittakeslessertimetocodeJUnitmethodsandtestthemonclass
files.
HowtoinstallJUnit?
Followthestepsbelow
DownloadthelatestversionofJUnit,referredtobelowasjunit.zip.
Unzipthejunit.zipdistributionfiletoadirectoryreferredtoas%JUNIT_HOME%.
AddJUnittotheclasspath
setCLASSPATH=%CLASSPATH%;%JUNIT_HOME%\junit.jar
TesttheinstallationbyrunningthesampletestsdistributedwithJUnit(sampletests
are located in the installation directory directly, not the junit.jar file). Then simply
type
javaorg.junit.runner.JUnitCoreorg.junit.tests.AllTests
Allthetestsshouldpasswithan"OK"message.Ifthetestsdon'tpass,verifythat
junit.jarisintheCLASSPATH.
WhydoesJUnitonlyreportthefirstfailureinasingletest?
Reportingmultiplefailuresinasingletestisgenerallyasignthatthetestdoestoomuchand
it is too big a unit test. JUnit is designed to work best with a number of small tests. It
executes each test within a separate instance of the test class. It reports failure on each
test.
InJava,assertisakeyword.Won'tthisconflictwithJUnit'sassert()method?
JUnit 3.7 deprecated assert() and replaced it with assertTrue(), which works exactly the
sameway.JUnit4iscompatiblewiththeassertkeyword.IfyourunwiththeeaJVMswitch,
assertionsthatfailwillbereportedbyJUnit.
HowdoItestthingsthatmustberuninaJ2EEcontainer(e.g.servlets,EJBs)?
RefactoringJ2EEcomponentstodelegatefunctionalitytootherobjectsthatdon'thavetobe
runinaJ2EEcontainerwillimprovethedesignandtestabilityofthesoftware.Cactusisan
opensourceJUnitextensionthatcanbeusedforunittestingserversidejavacode.
NamethetoolswithwhichJUnitcanbeeasilyintegrated.
JUnitFrameworkcanbeeasilyintegratedwitheitherofthefollowings
Eclipse
Ant
Maven
WhatarethecorefeaturesofJUnit?
JUnittestframeworkprovidesfollowingimportantfeatures
Fixtures
Testsuites
Testrunners
JUnitclasses
Whatisafixture?
Fixtureisafixedstateofasetofobjectsusedasabaselineforrunningtests.Thepurposeof
atestfixtureistoensurethatthereisawellknownandfixedenvironmentinwhichtestsare
runsothatresultsarerepeatable.Itincludesfollowingmethods
setUp()methodwhichrunsbeforeeverytestinvocation.
tearDown()methodwhichrunsaftereverytestmethod.
Whatisatestsuite?
Testsuitemeansbundleafewunittestcasesandrunittogether.InJUnit,both@RunWith
and@Suiteannotationareusedtorunthesuitetest.
Whatisatestrunner?
Testrunnerisusedforexecutingthetestcases.
WhatareJUnitclasses?Listsomeofthem.
JUnitclassesareimportantclasseswhichareusedinwritingandtestingJUnits.Someofthe
importantclassesare
AssertItcontainsasetofassertmethods.
TestCaseItcontainsatestcasedefinesthefixturetorunmultipletests.
TestResultItcontainsmethodstocollecttheresultsofexecutingatestcase.
TestSuiteItisaCompositeofTests.
WhatareannotationsandhowaretheyusefulinJUnit?
Annotationsarelikemetatagsthatyoucanaddtoyoucodeandapplythemtomethodsor
inclass.TheannotationinJUnitgivesusinformationabouttestmethods,whichmethodsare
goingtorunbefore&aftertestmethods,whichmethodsrunbefore&afterallthemethods,
whichmethodsorclasswillbeignoreduringexecution.
HowwillyourunJUnitfromcommandwindow?
Followthestepsbelow
SettheCLASSPATH
Invoketherunner
javaorg.junit.runner.JUnitCore
Whatisthepurposeoforg.junit.Assertclass?
Thisclassprovidesasetofassertionmethodsusefulforwritingtests.Onlyfailedassertions
arerecorded.
Whatisthepurposeoforg.junit.TestResultclass?
ATestResultcollectstheresultsofexecutingatestcase.ItisaninstanceoftheCollecting
Parameterpattern.Thetestframeworkdistinguishesbetweenfailuresanderrors.Afailureis
anticipated and checked for with assertions. Errors are unanticipated problems like an
ArrayIndexOutOfBoundsException.
Whatisthepurposeoforg.junit.TestSuiteclass?
ATestSuiteisaCompositeofTests.Itrunsacollectionoftestcases.
Whatisthepurposeof@TestannotationinJUnit?
TheTestannotationtellsJUnitthatthepublicvoidmethodtowhichitisattachedcanberun
asatestcase.
Whatisthepurposeof@BeforeannotationinJUnit?
Several tests need similar objects created before they can run. Annotating a public void
methodwith@BeforecausesthatmethodtoberunbeforeeachTestmethod.
Whatisthepurposeof@AfterannotationinJUnit?
IfyouallocateexternalresourcesinaBeforemethodyouneedtoreleasethemafterthetest
runs. Annotating a public void method with @After causes that method to be run after the
Testmethod.
Whatisthepurposeof@BeforeClassannotationinJUnit?
Annotating a public static void method with @BeforeClass causes it to be run once before
anyofthetestmethodsintheclass.
Whatisthepurposeof@AfterClassannotationinJUnit?
Thiswillperformthemethodafteralltestshavefinished.Thiscanbeusedtoperformclean
upactivities.
Whatis@Ignoreannotationandhowisthisuseful?
Followingaresomeoftheusefulnessof@Ignoreannotation
You can easily identify all @Ignore annotations in the source code, while unannotated or
commentedouttestsarenotsosimpletofind.
Therearecaseswhenyoucan'tfixacodethatisfailing,butyoustillwanttomethodtobe
around,preciselysothatitdoesnotgetforgotten.Insuchcases@Ignoremakessense.
ExplaintheexecutionprocedureoftheJUinttestAPImethods?
FollowingishowtheJUnitexecutionprocedureworks
Firstofallmethodannotatedas@BeforeClassexecuteonlyonce.
Lastly,themethodannotatedas@AfterClassexecutesonlyonce.
Methodannotatedas@Beforeexecutesforeachtestcasebutbeforeexecutingthe
testcase.
Methodannotatedas@Afterexecutesforeachtestcasebutaftertheexecutionof
testcase.
Whatisthepurposeoforg.junit.JUnitCoreclass?
ThetestcasesareexecutedusingJUnitCoreclass.JUnitCoreisafacadeforrunningtests.It
supportsrunningJUnit4tests,JUnit3.8.xtests,andmixtures.
HowtosimulatetimeoutsituationinJUnit?
Junit provides a handy option of Timeout. If a test case takes more time than specified
numberofmillisecondsthenJunitwillautomaticallymarkitasfailed.Thetimeoutparameter
isusedalongwith@Testannotation.
HowcanyouuseJUnittotestthatthecodethrowsdesiredexception?
JUnit provides a option of tracing the Exception handling of code. You can test if a code
throws desired exception or not. The expected parameter is used along with @Test
annotationasfollows@Test(expected)
WhatareParameterizedtests?
Junit 4 has introduced a new feature Parameterized tests. Parameterized tests allow
developertorunthesametestoverandoveragainusingdifferentvalues.
HowtocreateParameterizedtests?
Therearefivesteps,thatyouneedtofollowtocreateParameterizedtests
Annotatetestclasswith@RunWith(Parameterized.class).
Createapublicstaticmethodannotatedwith@ParametersthatreturnsaCollection
ofObjects(asArray)astestdataset.
Createapublicconstructorthattakesinwhatisequivalenttoone"row"oftestdata.
Createaninstancevariableforeach"column"oftestdata.
Createyourtestscase(s)usingtheinstancevariablesasthesourceofthetestdata.
The test case will be invoked once per each row of data. Let's see Parameterized
testsinaction.
Howdoyouusetestfixtures?
Fixturesisafixedstateofasetofobjectsusedasabaselineforrunningtests.Thepurpose
ofatestfixtureistoensurethatthereisawellknownandfixedenvironmentinwhichtests
arerunsothatresultsarerepeatable.Itincludes
setUp()methodwhichrunsbeforeeverytestinvocation.
tearDown()methodwhichrunsaftereverytestmethod.
HowtocompileaJUnitTestClass?
CompilingaJUnittestclassislikecompilinganyotherJavaclasses.Theonlythingyouneed
watchoutisthattheJUnitJARfilemustbeincludedintheclasspath.
WhathappensifaJUnitTestMethodisDeclaredas"private"?
IfaJUnittestmethodisdeclaredas"private",itcompilessuccessfully.Buttheexecutionwill
fail.ThisisbecauseJUnitrequiresthatalltestmethodsmustbedeclaredas"public".
Howdoyoutesta"protected"method?
Whenamethodisdeclaredas"protected",itcanonlybeaccessedwithinthesamepackage
wheretheclassisdefined.Hencetotesta"protected"methodofatargetclass,defineyour
testclassinthesamepackageasthetargetclass.
Howdoyoutesta"private"method?
Whenamethodisdeclaredas"private",itcanonlybeaccessedwithinthesameclass.So
thereisnowaytotesta"private"methodofatargetclassfromanytestclass.Henceyou
needtoperformunittestingmanually.Oryouhavetochangeyourmethodfrom"private"to
"protected".
WhathappensifaJUnittestmethodisdeclaredtoreturn"String"?
If a JUnit test method is declared to return "String", the compilation will pass ok. But the
executionwillfail.ThisisbecauseJUnitrequiresthatalltestmethodsmustbedeclaredto
return"void".
Canyouuseamain()MethodforUnitTesting?
Yes you can test using main() method. One obvious advantage seems to be that you can
whitebox test the class. That is, you can test the internals of it (private methods for
example). You can't do that with unittests. But primarily the test framework tests the
interfaceandthebehaviorfromtheuser'sperspective.
Doyouneedtowriteatestclassforeveryclassthatneedstobetested?
No.Weneednotwriteanindependenttestclassforeveryclassthatneedstobetested.If
thereisasmallgroupoftestssharingacommontestfixture,youmaymovethoseteststo
anewtestclass.
Whenaretestsgarbagecollected?
The test runner holds strong references to all Test instances for the duration of the test
execution. This means that for a very long test run with many Test instances, none of the
tests may be garbage collected until the end of the entire test run. Explicitly setting an
object to null in the tearDown() method, for example, allows it to be garbage collected
beforetheendoftheentiretestrun.
WhatisaMockObject?
Inaunittest,mockobjectscansimulatethebehaviorofcomplex,real(nonmock)objects
andarethereforeusefulwhenarealobjectisimpracticalorimpossibletoincorporateintoa
unittest.
ExplainunittestingusingMockObjects.
Thecommoncodingstylefortestingwithmockobjectsisto
Createinstancesofmockobjects.
Setstateandexpectationsinthemockobjects.
Invokedomaincodewithmockobjectsasparameters.
Verifyconsistencyinthemockobjects.
NamesomeoftheJUnitExtensions.
FollowingaretheJUnitextensions
Cactus
JWebUnit
XMLUnit
MockObject
WhatisCactus?
Cactusisasimpletestframeworkforunittestingserversidejavacode(Servlets,EJBs,Tag
Libs,Filters).TheintentofCactusistolowerthecostofwritingtestsforserversidecode.It
usesJUnitandextendsit.Cactusimplementsanincontainerstrategy,meaningthattests
areexecutedinsidethecontainer.
WhatarethecorecomponentsofCactus?
CactusEcosystemismadeofseveralcomponents
Cactus Framework is the heart of Cactus. It is the engine that provides the API to
writeCactustests.
CactusIntegrationModulesarefrontendsandframeworksthatprovideeasywaysof
usingtheCactusFramework(Antscripts,Eclipseplugin,Mavenplugin).
WhatisJWebUnit?
WebUnit is a Javabased testing framework for web applications. It wraps existing testing
frameworkssuchasHtmlUnitandSeleniumwithaunified,simpletestinginterfacetoallow
youtoquicklytestthecorrectnessofyourwebapplications.
WhataretheadvantagesofusingJWebUnit?
JWebUnitprovidesahighlevelJavaAPIfornavigatingawebapplicationcombinedwithaset
ofassertionstoverifytheapplication'scorrectness.Thisincludesnavigationvialinks,form
entryandsubmission,validationoftablecontents,andothertypicalbusinesswebapplication
features.
The simple navigation methods and readytouse assertions allow for more rapid test
creationthanusingonlyJUnitorHtmlUnit.AndifyouwanttoswitchfromHtmlUnittoother
pluginssuchasSelenium(availablesoon),thereisnoneedtorewriteyourtests.
WhatisXMLUnit?
XMLUnit provides a single JUnit extension class, XMLTestCase, and a set of supporting
classes.
WhatistheuseofsupportingclassesinXMLUnit?
Supportingclassesallowassertionstobemadeabout
ThedifferencesbetweentwopiecesofXML(viaDiffandDetailedDiffclasses).
ThevalidityofapieceofXML(viaValidatorclass).
TheoutcomeoftransformingapieceofXMLusingXSLT(viaTransformclass).
TheevaluationofanXPathexpressiononapieceofXML(viaclassesimplementing
theXpathEngineinterface).
IndividualnodesinapieceofXMLthatareexposedbyDOMTraversal(viaNodeTest
class).
WhatisNext?
Furtheryoucangothroughyourpastassignmentsyouhavedonewiththesubjectandmake
sureyouareabletospeakconfidentlyonthem.Ifyouarefreshertheninterviewerdoesnot
expect you will answer very complex questions, rather you have to make your basics
conceptsverystrong.
Second it really doesn't matter much if you could not answer few questions but it matters
that whatever you answered, you must have answered with confidence. So just feel
confident during your interview. We at tutorialspoint wish you best luck to have a good
interviewerandalltheverybestforyourfutureendeavor.Cheers:)
PreviousPage NextPage
JUnitOnlineQuiz
Advertisements
QuestionsPage NextQuiz
FollowingquizprovidesMultipleChoiceQuestions(MCQs)relatedtoJUnitFramework.You
willhavetoreadallthegivenanswersandclickoverthecorrectanswer.Ifyouarenotsure
about the answer then you can check the answer using Show Answer button. You can
useNextQuizbuttontochecknewsetofquestionsinthequiz.
Q1WhichofthefollowingiscorrectaboutJUnit?
AJUnittestscanbeorganizedintotestsuitescontainingtestcasesandevenothertest
suites.
B JUnit shows test progress in a bar that is green if test is going fine and it turns red
whenatestfailsineclipse.
CBothoftheabove.
DNoneoftheabove.
Answer:C
Explanation
JUnit tests can be organized into test suites containing test cases and even other test
suites.JUnitshowstestprogressinabarthatisgreeniftestisgoingfineanditturnsred
whenatestfailsineclipse.
ShowAnswer
Q2WhichofthefollowingiscorrectaboutaUnitTestCase?
ATheremustbeatleasttwounittestcasesforeachrequirement:onepositivetestand
onenegativetest.
BIfarequirementhassubrequirements,eachsubrequirementmusthaveatleasttwo
testcasesaspositiveandnegative.
CBothoftheabove.
DNoneoftheabove.
Answer:C
Explanation
There must be at least two unit test cases for each requirement: one positive test and
one negative test. If a requirement has subrequirements, each subrequirement must
haveatleasttwotestcasesaspositiveandnegative.
HideAnswer
Q3WhichofthefollowingclassisaCompositeofTests?
AAssert
BTestCase
CTestResult
DTestSuite
Answer:D
Explanation
TestSuiteclassisaCompositeofTests.
HideAnswer
Q4WhichofthefollowingmethodofAssertclasschecksthatanobjectisnull?
Avoidassert(Objectobject,booleantoCheckAsNull)
BvoidassertCheck(Objectobject,booleantoCheckAsNull)
CvoidassertNull(Objectobject)
DvoidassertChecks(Objectobject,booleantoCheckAsNull)
Answer:C
Explanation
voidassertNull(Objectobject)checksthatanobjectisnull.
HideAnswer
AStringgetTestName()
BStringgetNameOfTest()
CStringgetName()
DStringgetTestCase()
Answer:C
Explanation
StringgetName()methodgetsthenameofaTestCase.
HideAnswer
Ainterror()
BinterrorCount()
CintfailureCount()
Dintfailure()
Answer:C
Explanation
intfailureCount()methodgetsthenumberofdetectedfailures.
HideAnswer
AinttestCount()
BinttestCaseCount()
CintgetTestCount()
DinttestSuiteCount()
Answer:A
Explanation
inttestCount()methodreturnsthenumberoftestsinthissuite.
HideAnswer
Q8Ifatestclassisannotatedwith@Ignorethennoneofitstestmethodswill
beexecuted.
Afalse
Btrue
Answer:B
Explanation
Ifatestclassisannotatedwith@Ignorethennoneofitstestmethodswillbeexecuted.
HideAnswer
Q9JUnitprovidesTestrunnersforrunningtests.
Atrue
Bfalse
Answer:A
Explanation
JUnitprovidesTestrunnersforrunningtests.
HideAnswer
Q10FixtureincludessetUp()methodwhichrunsoncewhentestclassloads.
Atrue
Bfalse
Answer:B
Explanation
Explanation
FixtureincludessetUp()methodwhichrunsbeforeeverytestinvocation.
HideAnswer
QuestionsPage NextQuiz
JUnitOnlineTest
Advertisements
PreviousPage NextPage
This JUnit Online Test simulates a real online certification exams. You will be presented
MultipleChoiceQuestions(MCQs)basedonJUnitFrameworkConcepts,whereyouwillbe
givenfouroptions.Youwillselectthebestsuitableanswerforthequestionandthenproceed
to the next question without wasting given time. You will get your online test score after
finishingthecompletetest.
Youscored35%
TotalQuestions:20,Attempted:20,Correct:7,TimeTaken:0.95Min
QWhichofthefollowingiscorrectaboutautomatedtesting?
AAutomationtestsperformpreciselysameoperationeachtimetheyarerun.
BTesterscanprogramsophisticatedteststobringouthiddeninformation.
CBothoftheabove.
DNoneoftheabove.
Answer:C
Explanation
Automationtestsperformpreciselysameoperationeachtimetheyarerun.Testerscan
programsophisticatedteststobringouthiddeninformation.
ShowAnswer
Q JUnit tests can be run automatically and they check their own results and
provideimmediatefeedback.
Atrue
Bfalse
Answer:A
Explanation
JUnit tests can be run automatically and they check their own results and provide
immediatefeedback.
ShowAnswer
QWhichofthefollowingiscorrectaboutTestSuiteinJUnit?
ATestsuitemeansbundleafewunittestcasesandrunittogether.
B@RunWithand@Suiteannotationareusedtorunthesuitetest.
CBothoftheabove
DNoneoftheabove.
Answer:C
Explanation
Test suite means bundle a few unit test cases and run it together. In JUnit, both
@RunWithand@Suiteannotationareusedtorunthesuitetest.
ShowAnswer
QAnnotatingapublicvoidmethodwith@BeforeClasscausesthatmethodtobe
runbeforeeachTestmethod.
Afalse
Btrue
Answer:A
Explanation
Annotatingapublicstaticvoidmethodwith@BeforeClasscausesittoberunoncebefore
anyofthetestmethodsintheclass.
ShowAnswer
Bfalse
Answer:A
Explanation
Annotatetestclasswith@RunWith(Parameterized.class)tocreateaparameterizedtest
case.
ShowAnswer
QWhichofthefollowingmethodofTestResultclassaddsanerrortothelistof
errors?
AvoidaddError(Testtest,Throwablet)
BvoidaddError(Testtest,Errort)
CvoidaddError(Testtest,Exceptiont)
DvoidaddError(Testtest,TestErrort)
Answer:A
Explanation
voidaddError(Testtest,Throwablet)methodaddsanerrortothelistoferrors.
ShowAnswer
Q WhichofthefollowingmethodofTestSuiteclasscountsthenumberoftest
casesthatwillberunbythistest?
AintcountTestExecutions()
BintcountTest()
Cintcount()
DintcountTestCases()
Answer:D
Explanation
intcountTestCases()methodcountsthenumberoftestcasesthatwillberunbythistest.
ShowAnswer
AvoidsetTestName()
BvoidsetNameOfTest()
CvoidsetName()
DvoidsetTestCase()
Answer:C
Explanation
voidsetName()methodsetsthenameofaTestCase.
ShowAnswer
QWhichofthefollowingiscorrectaboutFixture?
AFixtureisafixedstateofasetofobjectsusedasabaselineforrunningtests.
B The purpose of a test fixture is to ensure that there is a well known and fixed
environmentinwhichtestsarerunsothatresultsarerepeatable.
CBothoftheabove
DNoneoftheabove.
Answer:C
Explanation
Fixture is a fixed state of a set of objects used as a baseline for running tests. The
purposeofatestfixtureistoensurethatthereisawellknownandfixedenvironmentin
whichtestsarerunsothatresultsarerepeatable.
ShowAnswer
QWhichofthefollowingiscorrectaboutJUnitexecutionprocedure?
AFirstofallmethodannotatedas@BeforeClassexecuteonlyonce.
BLastly,themethodannotatedas@AfterClassexecutesonlyonce.
CMethodannotatedas@Beforeexecutesforeachtestcasebutbeforeexecutingthetest
case.
DAlloftheabove.
Answer:D
Explanation
Alloftheaboveoptionsarecorrect.
ShowAnswer
QJUnitprovidesAssertionsfortestingexpectedresults.
Atrue
Bfalse
Answer:A
Explanation
JUnitprovidesAssertionsfortestingexpectedresults.
ShowAnswer
QWhichofthefollowingiscorrectaboutorg.junit.JUnitCoreclass?
AThetestcasesareexecutedusingJUnitCoreclass.
BJUnitCoreisafacadeforrunningtests.
CItsupportsrunningJUnit4tests,JUnit3.8.xtests,andmixtures.
DAlloftheabove.
Answer:D
Explanation
ThetestcasesareexecutedusingJUnitCoreclass.JUnitCoreisafacadeforrunningtests.
ItsupportsrunningJUnit4tests,JUnit3.8.xtests,andmixtures.
ShowAnswer
Q@RunWithand@Suiteannotationareusedtorunthesuitetest.
Afalse
Btrue
Answer:B
Explanation
Both@RunWithand@Suiteannotationareusedtorunthesuitetest.
ShowAnswer
QWhichofthefollowingannotationcausesthatmethodtoberunbeforeeach
Testmethod?
A@Test
B@Before
C@After
D@BeforeClass
Answer:B
Explanation
Annotatingapublicvoidmethodwith@Beforecausesthatmethodtoberunbeforeeach
Testmethod.
ShowAnswer
QWhichofthefollowingiscorrectaboutJUnit?
AItisanopensourceframework.
BItprovidesAnnotationtoidentifythetestmethods.
CItprovidesAssertionsfortestingexpectedresults.
DAlloftheabove.
Answer:D
Explanation
Alloftheaboveoptionsarecorrect.
ShowAnswer
QWhichofthefollowingmethodofTestResultclassrunsaTestCase?
Avoidrun(TestCasetest)
Bvoidexecute(TestCasetest)
CvoidrunTest(TestCasetest)
DvoidexecuteTest(TestCasetest)
Answer:A
Explanation
voidrun(TestCasetest)methodrunsaTestCase.
ShowAnswer
QWhichofthefollowingiscorrectaboutaUnitTestCase?
ATheremustbeatleasttwounittestcasesforeachrequirement:onepositivetestand
onenegativetest.
BIfarequirementhassubrequirements,eachsubrequirementmusthaveatleasttwo
testcasesaspositiveandnegative.
CBothoftheabove.
DNoneoftheabove.
Answer:C
Explanation
There must be at least two unit test cases for each requirement: one positive test and
one negative test. If a requirement has subrequirements, each subrequirement must
haveatleasttwotestcasesaspositiveandnegative.
ShowAnswer
QWhichofthefollowingiscorrectaboutaUnitTestCase?
AAUnitTestCaseisapartofcodewhichensuresthattheanotherpartofcode(method)
worksasexpected.
BAformalwrittenunittestcaseischaracterizedbyaknowninputandbyanexpected
output,whichisworkedoutbeforethetestisexecuted.
C The known input should test a precondition and the expected output should test a
postcondition.
DAlloftheabove.
Answer:D
Explanation
Alloftheaboveoptionsarecorrect.
ShowAnswer
Q Which of the following method of TestResult class gets the number of run
tests?
AinttestCount()
BintrunCount()
CintcountExecutions()
DintcountRun()
Answer:B
Explanation
intrunCount()methodgetsthenumberofruntests.
ShowAnswer
AvoidassertEquals(booleanexpected,booleanactual)
Bvoidassert(booleanexpected,booleanactual)
CvoidassertCheck(booleanexpected,booleanactual)
DvoidassertChecks(booleanexpected,booleanactual)
Answer:A
Explanation
voidassertEquals(booleanexpected,booleanactual)checksthattwoprimitives/Objects
areequal.
ShowAnswer
NewTest
JUNIT MOCK TEST
http://www.tutorialspoint.com Copyright tutorialspoint.com
This section presents you various set of Mock Tests related to JUnit Framework. You can
download these sample mock tests at your local machine and solve offline at your convenience.
Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.
A - Testing is the process of checking the functionality of the application whether it is working as
per requirements.
A - Unit Testing is the process of checking the functionality of the application whether it is
working as per requirements.
A - Since test cases are executed by human resources so it is very slow and tedious.
B - As test cases need to be executed manually so more testers are required in manual testing.
A - Manual testing is less reliable as tests may not be performed with precision each time
because of human errors.
B - No programming can be done to write sophisticated tests which fetch hidden information.
B - Test cases are executed by using automation tool so less tester are required in automation
testing.
A - Automation tests perform precisely same operation each time they are run.
B - JUnit tests can be run automatically and they check their own results and provide immediate
feedback.
A - JUnit tests can be organized into test suites containing test cases and even other test suites.
B - JUnit shows test progress in a bar that is green if test is going fine and it turns red when a test
fails in eclipse.
A - A Unit Test Case is a part of code which ensures that the another part of code method works as
expected.
B - A formal written unit test case is characterized by a known input and by an expected output,
which is worked out before the test is executed.
C - The known input should test a precondition and the expected output should test a
postcondition.
A - There must be at least two unit test cases for each requirement: one positive test and one
negative test.
B - If a requirement has sub-requirements, each sub-requirement must have at least two test
cases as positive and negative.
A - Unit Tests are to be written before the code during development in order to help coders write
the best code.
B - Unit Tests are written after the code during development in order to help coders test the
code.
A - Eclipse
B - Ant
C - Maven
A - Fixture is a fixed state of a set of objects used as a baseline for running tests.
B - The purpose of a test fixture is to ensure that there is a well known and fixed environment in
which tests are run so that results are repeatable.
A - Fixture includes setUp method which runs before every test invocation.
B - Fixture includes tearDown method which runs after every test method.
A - Test suite means bundle a few unit test cases and run it together.
B - @RunWith and @Suite annotation are used to run the suite test.
B - @RunWith and @Suite annotation are used to run the test runner.
A - Assert
B - TestCase
C - TestResult
D - TestSuite
Q 19 - Which of the following class contains a test case and defines the fixture to run
multiple tests?
A - Assert
B - TestCase
C - TestResult
D - TestSuite
A - Assert
B - TestCase
C - TestResult
D - TestSuite
A - Assert
B - TestCase
C - TestResult
D - TestSuite
Q 22 - Which of the following annotation tells JUnit that the public void method to
which it is attached can be run as a test case?
A - @Test
B - @Before
C - @After
D - @BeforeClass
Q 23 - Which of the following annotation causes that method to be run before each
Test method?
A - @Test
B - @Before
C - @After
D - @BeforeClass
Q 24 - Which of the following annotation causes that method to be run after each Test
method?
A - @Test
B - @Before
C - @After
D - @AfterClass
Q 25 - Which of the following annotation causes that method run once before any of
the test methods in the class?
A - @Test
B - @Before
C - @BeforeClass
D - @AfterClass
ANSWER SHEET
1 A
2 B
3 C
4 C
5 C
6 C
7 D
8 C
9 C
10 D
11 C
12 A
13 D
14 C
15 C
16 C
17 A
18 A
19 B
20 C
21 D
22 A
23 B
24 C
25 C
Loading [MathJax]/jax/output/HTML-CSS/jax.js
JUNIT MOCK TEST
http://www.tutorialspoint.com Copyright tutorialspoint.com
This section presents you various set of Mock Tests related to JUnit Framework. You can
download these sample mock tests at your local machine and solve offline at your convenience.
Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.
Q 1 - Which of the following annotation causes that method run once after all tests
have finished?
A - @Test
B - @After
C - @BeforeClass
D - @AfterClass
C - Method annotated as @Before executes for each test case but before executing the test case.
A - Method annotated as @After executes for each test case but after the execution of test case.
B - In between method annotated as @Before and method annotated as @After each test case
executes.
Q 6 - Which of the following method of Assert class checks that two primitives/Objects
are equal?
Q 7 - Which of the following method of Assert class checks that a condition is true?
A - void assertbooleancondition
B - void assertTruebooleancondition
C - void assertCheckbooleancondition
D - void assertChecksbooleancondition
Q 8 - Which of the following method of Assert class checks that a condition is false?
A - void assertbooleancondition
B - void assertFalsebooleancondition
C - void assertCheckbooleancondition
D - void assertChecksbooleancondition
Q 9 - Which of the following method of Assert class checks that an object isn't null?
C - void assertNotNullObjectobject
C - void assertNullObjectobject
Q 11 - Which of the following method of Assert class checks if two object references
point to the same object?
Q 12 - Which of the following method of Assert class checks if two object references
are not pointing to the same object?
Q 13 - Which of the following method of Assert class checks whether two arrays are
equal to each other?
Q 14 - Which of the following method of Assert class fails a test with no message?
A - void assertChecksbooleanpass
B - void assertCheckbooleanpass
C - void assertbooleanpass
D - void fail
Q 15 - Which of the following method of TestCase class counts the number of test
cases executed by runTestResultresult?
A - int countTestCases
B - int executedTestCases
C - int getTestCaseCount
D - int testCases
A - TestResult getTestResult
B - TestResult createResult
C - TestResult getTestResultInstance
D - TestResult testResult
Q 17 - Which of the following method of TestCase class gets the name of a TestCase?
A - String getTestName
B - String getNameOfTest
C - String getName
D - String getTestCase
Q 18 - Which of the following method of TestCase class runs a test, collecting the
results with a default TestResult object?
A - TestResult runTestCase
B - TestResult runTest
C - TestResult runTestAndSave
D - TestResult run
Q 19 - Which of the following method of TestCase class runs the test case and collects
the results in TestResult?
Q 20 - Which of the following method of TestCase class sets the name of a TestCase?
A - void setTestName
B - void setNameOfTest
C - void setName
D - void setTestCase
Q 21 - Which of the following method of TestCase class sets up the fixture, for
example, open a network connection?
A - void setTestName
B - void setUp
C - void setUpFixture
D - void setTestCase
Q 22 - Which of the following method of TestCase class tears down the fixture, for
example, close a network connection?
A - void tearDownTestName
B - void tearDown
C - void tearDownFixture
D - void tearDownTestCase
Q 23 - Which of the following method of TestResult class adds an error to the list of
errors?
Q 24 - Which of the following method of TestResult class adds a failure to the list of
failures?
Q 25 - Which of the following method of TestResult class informs the result that a test
was completed?
A - void showResultTesttest
B - void getResultTesttest
C - void endTestTesttest
D - void startTestTesttest
ANSWER SHEET
Question Number Answer Key
1 D
2 D
3 C
4 D
5 D
6 A
7 B
8 B
9 C
10 C
11 C
12 C
13 C
14 D
15 A
16 B
17 C
18 D
19 D
20 C
21 B
22 B
23 A
24 B
25 C
This section presents you various set of Mock Tests related to JUnit Framework. You can
download these sample mock tests at your local machine and solve offline at your convenience.
Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.
Q 1 - Which of the following method of TestResult class gets the number of detected
errors?
A - int getErrors
B - int errorCount
C - int countErrors
D - int getErrorCount
A - Enumeration<Object> errors
B - Enumeration<TestFailure> errors
C - Enumeration<TestFailure> getErrors
D - Enumeration<Object> getErrors
Q 3 - Which of the following method of TestResult class gets the number of detected
failures?
A - int error
B - int errorCount
C - int failureCount
D - int failure
B - void executeTestCasetest
C - void runTestTestCasetest
D - void executeTestTestCasetest
Q 5 - Which of the following method of TestResult class gets the number of run tests?
A - int testCount
B - int runCount
C - int countExecutions
D - int countRun
Q 6 - Which of the following method of TestResult class informs the result that a test
will be started?
A - void startTestTesttest
B - void startTesttest
C - void executeTesttest
D - void executeTestTesttest
Q 7 - Which of the following method of TestResult class marks that the test run should
stop?
A - void stopTest
B - void stop
C - void stopTestTesttest
D - void breakTestTesttest
Q 8 - Which of the following method of TestSuite class adds a test to the suite?
A - void addTest
B - void add
C - void addTestTesttest
D - void addTestCaseTesttest
Q 9 - Which of the following method of TestSuite class adds the tests from the given
class to the suite?
C - void addTestTestCasetestClass
D - void addTestCaseTestCasetestClass
Q 10 - Which of the following method of TestSuite class counts the number of test
cases that will be run by this test?
A - int countTestExecutions
B - int countTest
C - int count
D - int countTestCases
Q 11 - Which of the following method of TestSuite class returns the name of the suite?
A - String getNameOfTestSuite
B - String getTestName
C - String getName
D - String getTestSuite
Q 12 - Which of the following method of TestSuite class runs the tests and collects
their result in a TestResult?
A - void executeTestResultresult
B - void runTestTestResultresult
C - void runTestResultresult
D - void executeTestTestResultresult
Q 13 - Which of the following method of TestSuite class sets the name of the suite?
A - void setSuiteNameStringname
B - void setNameStringname
C - void setTestSuiteNameStringname
D - void setTestNameStringname
Q 14 - Which of the following method of TestSuite class returns the test at the given
index?
A - Test testAtintindex
B - Test testAtIndexintindex
C - Test getTestAtintindex
D - Test testintindex
Q 15 - Which of the following method of TestSuite class returns the number of tests in
this suite?
A - int testCount
B - int testCaseCount
C - int getTestCount
D - int testSuiteCount
Q 16 - Which of the following method of TestSuite class returns a test which will fail
and log a warning message?
Q 17 - The @Test annotation tells JUnit that the public void method to which it is
attached can be run as a test case.
A - true
B - false
Q 18 - Annotating a public void method with @Before causes that method to be run
before each Test method.
A - false
B - true
Q 19 - Annotating a public void method with @After causes that method to be run
after each Test method.
A - false
B - true
A - false
B - true
A - false
B - true
Q 22 - The @Ignore annotation is used to ignore the test and that test will not be
executed.
A - false
B - true
A - JUnitCore
B - TestCase
C - TestSuite
D - TestResult
Q 24 - Which of the following class is used to bundle unit test cases and run them
together?
A - JUnitCore
B - TestCase
C - TestSuite
D - TestResult
Q 25 - @RunWith and @Suite annotation are used to run the suite test.
A - false
B - true
ANSWER SHEET
1 B
2 C
3 C
4 A
5 B
6 A
7 B
8 C
9 B
10 D
11 C
12 C
13 B
14 A
15 A
16 D
17 A
18 B
19 B
20 A
21 A
22 B
23 A
24 C
25 B
This section presents you various set of Mock Tests related to JUnit Framework. You can
download these sample mock tests at your local machine and solve offline at your convenience.
Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.
Q 1 - @RunWith and @Suite annotation are used to run the suite test.
A - false
B - true
A - false
B - true
Q 3 - If a test class is annotated with @Ignore then none of its test methods will be
executed.
A - false
B - true
Q 4 - @Test annotation along with timeout attribute can be used to set timeout of a
test case.
A - false
B - true
Q 5 - @Test annotation along with expected attribute can be used to test the code
whether code throws desired exception or not.
A - true
B - false
Q 6 - Parameterized tests allow developer to run the same test over and over again
using same values.
A - true
B - false
A - true
B - false
A - true
B - false
A - true
B - false
A - true
B - false
Q 11 - Automated Test cases are executed by using automation tool so less tester are
required in automation testing.
A - true
B - false
A - true
B - false
A - true
B - false
Q 14 - JUnit provides Assertions for testing expected results.
A - true
B - false
A - true
B - false
Q 16 - JUnit tests can be run automatically and they check their own results and
provide immediate feedback.
A - true
B - false
Q 17 - Unit Tests are to be written before the code during development in order to
help coders write the best code.
A - true
B - false
Q 18 - Unit Tests are written after the code during development in order to help
coders test the code.
A - true
B - false
A - true
B - false
Q 20 - Fixture includes setUp method which runs before every test invocation.
A - true
B - false
Q 21 - Fixture includes setUp method which runs once when test class loads.
A - true
B - false
Q 22 - Fixture includes tearDown method which runs after every test method.
A - true
B - false
Q 23 - Fixture includes tearDown method which runs after all test methods get
executed.
A - true
B - false
A - true
B - false
Q 25 - TestCase contains a test case and defines the fixture to run multiple tests.
A - true
B - false
ANSWER SHEET
1 B
2 B
3 B
4 B
5 A
6 B
7 A
8 A
9 B
10 A
11 A
12 B
13 A
14 A
15 A
16 A
17 A
18 B
19 A
20 A
21 B
22 A
23 B
24 A
25 A
Loading [MathJax]/jax/output/HTML-CSS/jax.js
http://career.guru99.com/
JUnit is a testing framework for unit testing. It uses Java as a programming platform, and it is
an Open Source Software managed by the JUnit.org community.
Unit Test Case is a part of the code that ensures that the another part of code (method)
behaves as expected. For each requirement, there must be at least two test cases one negative
test and one positive test.
Determine one or more public test XYZ() methods that exercise the objects under test and
assert expected results.
Parameterized tests enable developer to perform the same test over and again using different
values.
JUnit TestNG
In JUnit the naming convention for In TestNG it is easier to understand
annotation is a bit complicated for, annotations like BeforMethod,
e.g., Before, After and AfterMethod and
Expected ExpectedException
In JUnit, for a method declaration In TestNG, there is no restriction
you have to follow a specific style like you have to declare methods in
like using @BeforeClass and a specific format
1/4
http://career.guru99.com/
When your code is not ready, and it would fail if executed then you can use @Ignore
annotation.
2/4
http://career.guru99.com/
Cactus
JWebUnit
XMLUnit
MockObject
9) Explain who should use JUnit - a developer or tester? Why you use JUnit to test your
code?
JUnit is more often used by developers to implement unit tests in JAVA. It is designed for unit
testing that is more a coding process and not a testing process. However, many testers and QA
engineers use JUnit for unit testing.
JUnitCore class is an inbuilt class in JUnit package; it is based on Faade design pattern, this
class is used to run only definite test classes only.
11) Explain how you can run JUnit from the command window?
To run JUnit from the command window, you have to follow the steps
Java org.junit.runner.JUnitCore
3/4
http://career.guru99.com/
4/4
Powered by TCPDF (www.tcpdf.org)
HOME CORE JAVA OOPS JAVA COLLECTIONS JAVA I/O JSON JSP JSTL
Follow
4,682 followers
t here: JUnit interview questions
st Case?
test method. Its really useful when we have all the tests
et to be tested for the particular test, in such scenarios
e marked with @Ignore annotation.
follows:
JUNIT_HOME%junit.jar
re class?
f @Rule annotation?
Exception.class)
ting only a single exception.
RECENTLY ADDED..
JSON Tutorial
JUnit Interview
JavaServer Pages - ABOUT CHAITANYA
JSP SINGH
Founder
of
beginners
Book.com,
loves Java and open
source stuff.
BeginnersBook.com is
a tech blog where he
shares tutorials on
programming (Java, C,
CPP), WordPress, SEO
and web development.
This is Part 2 of Q&A. Read rst part here JUnit (Java Unit Testing) interview questions and
answers Part1.
Question1: What is Junit?
1. Junit is open source testing framework developed for unit testing java code and is now the
default framework for testing Java development.
2. It has been developed by Erich Gamma and Kent Beck.
3. It is an application programming interface for developing test cases in java which is part of the
XUnit Family.
4. It helps the developer to write and execute repeatable automated tests.
5. Eclipse IDEcomes with both Junit and its plug-in for working with Junit.
6. Junit also has been ported to various other languages like PHP, Python, C++ etc.
Answer:Used by developers to implement unit tests in Java. Junit is designed for unit testing, which
is really a coding process, not a testing process. But many testers or QA engineers are also required
to use Junit for unit testing.
setCLASSPATH=%CLASSPATH%;%JUNIT_HOME%junit.jar
4. Test the installation by running the sample tests that come along with Junit located in the
installation directory. Therefore, make sure that the JUnit installation directory is on your
CLASSPATH. Then simply type:
java org.junit.runner.JUnitCore org.junit.tests.AllTests
All the tests should pass with an OK message. If the tests dont pass, verify that junit.jar is in the
CLASSPATH.
Answer:A unit test is nothing more than the code wrapper around the application code that can be
executed to view pass fail results.
Answer:Tests are written before the code during development in order to help coders write the best
code. Test-driven development is the ideal way to create a bug free code. When all tests pass, you
know you are done! Whenever a test fails or a bug is reported, we must rst write the necessary unit
test(s) to expose the bug(s), and then x them. This makes it almost impossible for that particular bug
to resurface later.
Dene one or more public testXYZ() methods that exercise the object(s) under test and assert
expected results.
Answer:JUnit TestCase is the base class, junit.framework.TestCase, that allows you to create a test
case. (Although, TestCase class is no longer supported in JUnit 4.4.)
A test case denes the xture to run multiple tests. To dene a test case
Each test runs in its own xture so there can be no side effects among test runs.
Answer:A test xture is a xed state of a set of objects used as a baseline for running tests. Their
purpose is to ensure that there is a well known and xed environment in which tests are run so that
results are repeatable. Examples of xtures:
If a group of tests shares the same xtures, you should write a separate setup code to create the
common test xture. If a group of tests requires different test xtures, you can write code inside the
test method to create its own test xture.
Answer:If a Junit test method is declared as private, the compilation will pass ok. But the execution
will fail. This is because Junit requires that all test methods must be declared as public.
Answer:If a Junit test method is declared to return String, the compilation will pass ok. But the
execution will fail. This is because Junit requires that all test methods must be declared to return
void.
Answer:Debugging the code using system.out.println() will lead to manual scanning of the whole
output every time the program is run to ensure the code is doing the expected operations. Moreover,
in the long run, it takes lesser time to code Junit methods and test them on our les.
Question14: The methods Get () and Set () should be tested for which conditions?
Answer:Unit tests performed on java code should be designed to target areas that might break.
Since the set() and get() methods on simple data types are unlikely to break, there is no need to test
them explicitly. On the other hand, set() and get() methods on complex data types are vulnerable to
break. So they should be tested.
Question15: For which conditions, the methods Get () and Set () can be left out for testing?
Answer:You should do this test to check if a property has already been set (in the constructor) at the
point you wish to call getX(). In this case you must test the constructor, and not the getX() method.
This kind of test is especially useful if you have multiple constructors.
Question16: Do you need to write a test class for every class that needs to be tested?
Answer:No. We need not write an independent test class for every class that needs to be tested. If
there is a small group of tests sharing a common test xture, you may move those tests to a new test
class. If you have two groups of tests that you think youd like to execute separately from one another,
it is wise to place them in separate test classes.
Answer:A protected method can only be accessed within the same package where the class is
dened. So, testing a protected method of a target class means we need to dene your test class in
the same package as the target class.
Answer:A private method only be accessed within the same class. So there is no way to test a
private method of a target class from any test class. A way out is that you can perform unit testing
manually or can change your method from private to protected.
Question19: Do you need to write a main () method compulsorily in a Junit test case class?
Answer:No. But still developers write the main() method in a JUnit test case class to call a JUnit test
runner to run all tests dened in this class like:
publicstaticvoidmain(String[]args){
junit.textui.TestRunner.run(Calculator.class);
}
Since you can call a JUnit runner to run a test case class as a system command, explicit main() for a
Junit test case is not recommended. junit.textui.TestRunner.run() method takes the test class name as
its argument. This method automatically nds all class methods whose name starts with test. Thus it
will result in below mentioned ndings:
1. testCreateLogFile()
2. testExists()
3. testGetChildList()
It will execute each of the 3 methods in unpredictable sequence (hence test case methods should be
independent of each other) and give the result in console.
Answer:If you write a test method that throws an exception by itself or by the method being tested,
the JUnit runner will declare that test as fail.
The example test below is designed to let the test fail by throwing the uncaught
IndexOutOfBoundsException exception:
importorg.junit.*;
importjava.util.*;
publicclassUnexpectedExceptionTest2{
//throwanyunexpectedexception
@TestpublicvoidtestGet()throwsException{
ArrayListemptyList=newArrayList();
ExceptionanyException=null;//don'tcatchanyexception
ExceptionanyException=null;//don'tcatchanyexception
Objecto=emptyList.get(1);}
}
OUTPUT:
There was 1 failure:
testGet(UnexpectedExceptionTest2)
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at UnexpectedExceptionTest2.testGet(UnexpectedExceptionTest2.ja
at sun.reect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reect.NativeMethodAccessorImpl.invoke(NativeMethodAcce
at sun.reect.DelegatingMethodAccessorImpl.invoke(DelegatingMe
at java.lang.reect.Method.invoke(Method.java:597)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java
at org.junit.internal.runners.MethodRoadie.runTestMethod(Method
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.j
at org.junit.internal.runners.MethodRoadie.runBeforesThenTestTh
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.jav
at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMetho
at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUni
at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4Cla
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassR
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoa
at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4Class
at org.junit.internal.runners.CompositeRunner.runChildren(Compo
at org.junit.internal.runners.CompositeRunner.run(CompositeRunn
at org.junit.runner.JUnitCore.run(JUnitCore.java:130)
at org.junit.runner.JUnitCore.run(JUnitCore.java:109)
at org.junit.runner.JUnitCore.run(JUnitCore.java:100)
at org.junit.runner.JUnitCore.runMain(JUnitCore.java:81)
at org.junit.runner.JUnitCore.main(JUnitCore.java:44)
FAILURES!!!
Answer:By design, the tree of Test instances is built in one pass. Then the tests are executed in a
second pass. The test runner holds strong references to all Test instances for the duration of the test
execution. This means that for a very long test run with many Test instances, none of the tests may be
garbage collected until the end of the entire test run. Therefore, if you allocate external or limited
resources in a test, you are responsible for freeing those resources. Explicitly setting an object to null
in the tearDown() method, for example, allows it to be garbage collected before the end of the entire
test run.
Answer:Java assertions allow the developer to put assert statements in Java source code to help
unit testing and debugging.
assertboolean_expression:string_expression;
Helper methods which help to determine if the methods being tested are performing correctly or not
assertEquals([String message], expected, actual)any kind of object can be used for testing
equality native types and objects, also specify tolerance when checking for equality in case of
oating point numbers.
assertNull([String message], java.lang.Objectobject)asserts that a given object is null
assertNotNull([String message], java.lang.Objectobject)asserts that a given object isnotnull
assertTrue([String message], Boolean condition)Asserts that the given Boolean condition is
true
assertFalse([String message], Boolean condition)Asserts that the given Boolean condition is
false
fail([String message])Fails the test immediately with the optional message
Example-:
publicvoidtestSum(){
intnum1=15;
intnum2=50;
inttotal=35;
intsum=0;
sum=num1+num2;
assertEquals(sum,total);
}
JUnitInterviewQuestionsandAnswers
Ques 13.Do You Need to Write a Test Class for Every Class That Need to Be Tested?
Ques 14.Can You Explain the Life Cycle of a JUnit3.8 Test Case Class?
Ques 15.Please Explain the Life Cycle of a JUnit 4.4 Test Class?
UnitTest
IntegrationTest
Ans.UnitTestareusuallyautomatedandIntegrationTestsareusuallyexecutedmanually.
2.WhatareJunits?
Ans.JuntistheunittestingframeworkforJava.
3.AreJunitstestedmanually?
Ans.No,theyareexecutedautomatically.
4.Howtotestwhetherthereturnsvalueofthemethodisexpected?
Ans.UsingAssert.
5.WhichpackageAssertbelongto?
Ans.java.unit
6.Whathappensiftheassertdoesn'tevaluatetobetrue?
Ans.Junitfails.
7.HowtocreateaJunittomakesurethatthetestedmethodthrowsanexception?
Ans.UsingannotationTestwiththeargumentasexpectedexception.
@Test(expected=Exception.class)
8.WhatshouldIdoifIwanttomakesurethataparticularmethodofaclassisgettingcalled
?
Ans.Ifitsastaticmethodoftheclass,wecanuseverifytomakesureit'sgettingcalled.
Ifitsaninstancemethod,Wecanmocktheobjectandthenuseverifywiththemockedobjecttomake
surethatthemethodisgettingcalled."
9.NamefewJavaMockingframeworks?
Ans.Mockito,PowerMock,EasyMock,JMock,JMockit
10.WhatistheuseofMockito.any?
Ans. In case we need to verify that a method is being called with any argument and not a specific
argumentwecanuseMockito.any(Class),Mockito.anyString,Mockito.anyLongetc.
11.Howshouldweignoreoravoidexecutingsetoftests?
Ans.Wecanremove@Testfromtherespectivetestsoastoavoiditsexecution.Alternativelywecanput
@IgnoreannotationontheJunitfileifwewanttoignorealltestsinaparticularfile.
12.Howcanwetestmethodsindividuallywhicharenotvisibleordeclaredprivate?
Ans.Wecaneitherincreasetheirvisibilityandmarkthemwithannotation@VisibleForTestingorcanuse
reflectiontoindividuallytestthosemethods.
InterviewQuestionsandAnswersfor'Junit'19question(s)foundOrderByNewest
Q1. How to create a Junit to make sure that the tested method admin
throwsanexception? info@buggybread.com
Ans.UsingannotationTestwiththeargumentasexpectedexception.
@Test(expected=Exception.class)
Help us improve. Please let us know the company, where you were asked this question :
admin
Q2.Howshouldweignoreoravoidexecutingsetoftests? info@buggybread.com
Ans.Wecanremove@Testfromtherespectivetestsoastoavoiditsexecution.Alternativelywe
canput@IgnoreannotationontheJunitfileifwewanttoignorealltestsinaparticularfile.
Help us improve. Please let us know the company, where you were asked this question :
Q3.Howcanwetestmethodsindividuallywhicharenotvisibleor admin
declaredprivate? info@buggybread.com
Ans. We can either increase their visibility and mark them with annotation @VisibleForTesting or
canusereflectiontoindividuallytestthosemethods.
Help us improve. Please let us know the company, where you were asked this question :
Q4. What are the steps to be performed while coding Junit with admin
Mockingframework? info@buggybread.com
Ans.Initializerequiredobjectsforworkingwithmocksandtestedmethod
Setthemockbehaviourondependentobjects
Executethetestedmethod
Performassertions
Verifyifamethodisinvokedornot
Help us improve. Please let us know the company, where you were asked this question :
Q5.Whatisassertkeywordusedfor? Anonymous
Ans.Theassertkeywordisusedtomakeanassertion astatementwhichtheprogrammer
believesisalwaystrueatthatpointintheprogram.Thiskeywordisintendedtoaidintestingand
debugging.
Help us improve. Please let us know the company, where you were asked this question :
admin
Q6.DifferencebetweenAssertandVerify? info@buggybread.com
Ans.Assertworksonlyifassertions(ea)areenabledwhichisnotrequiredforVerify.
Assert throws an exception and hence doesn't continue with the test if assert evaluates to false
whereasit'snotsowithVerify.
Help us improve. Please let us know the company, where you were asked this question :
Admin
Q7.WhataretheannotationsusedinJunitwithJunit4? info@buggybread.com
Ans.@Test
TheTestannotationindicatesthatthepublicvoidmethodtowhichitisattachedcanberunasa
testcase.
@Before
TheBeforeannotationindicatesthatthismethodmustbeexecutedbeforeeachtestintheclass,
soastoexecutesomepreconditionsnecessaryforthetest.
@BeforeClass
TheBeforeClassannotationindicatesthatthestaticmethodtowhichisattachedmustbeexecuted
onceandbeforealltestsintheclass.
@After
TheAfterannotationindicatesthatthismethodgetsexecutedafterexecutionofeachtest.
@AfterClass
TheAfterClassannotationcanbeusedwhenamethodneedstobeexecutedafterexecutingallthe
testsinaJUnitTestCaseclasssoastocleanupthesetup.
@Ignores
TheIgnoreannotationcanbeusedwhenyouwanttemporarilydisabletheexecutionofaspecific
test.
Help us improve. Please let us know the company, where you were asked this question :
Ans.Ifitsastaticmethodoftheclass,wecanuseverifytomakesureitsgettingcalled.
Ifitsaninstancemethod,Wecanmocktheobjectandthenuseverifywiththemockedobjectto
makesurethatthemethodisgettingcalled.
Help us improve. Please let us know the company, where you were asked this question :
admin
Q9.WhatistheuseofMockito.any? info@buggybread.com
Ans.Incaseweneedtoverifythatamethodisbeingcalledwithanyargumentandnotaspecific
argumentwecanuseMockito.any(Class),Mockito.anyString,Mockito.anyLongetc.
Help us improve. Please let us know the company, where you were asked this question :
Like Discuss junitmockitomockmockito.any
DoyouthinkthesearetheBestJavaFrameworks?
Checkeverything
SPRING Apache thatisBestinJava
MVC Stripes
ClickHere
OpenXava
admin
Q10.NamefewJavaMockingframeworks? info@buggybread.com
Ans.Mockito,PowerMock,EasyMock,JMock,JMockit
Help us improve. Please let us know the company, where you were asked this question :
Q11.Whichofthefollowingannotationisusedtoavoidexecuting Anonymous
Junits?
a.@explicit
b.@ignore
c.@avoid
d.@NoTest
Ans.@ignore
Help us improve. Please let us know the company, where you were asked this question :
a.Ithelpstestingthemoduleindependently
b.Ithelpsinfasterunittesting
c. It helps in testing code even when external dependencies like
servicecallsarenotworking
d.IthelpsindoingendtoendIntegrationTesting
Ans.IthelpsindoingendtoendIntegrationTesting
Help us improve. Please let us know the company, where you were asked this question :
Testing 2016110408:13:38
Q13.WriteaTestCaseusingMock?
Ans. http://javasearch.buggybread.com/CodeSnippets/searchCodeSamples.php?
keyword=mock&category=code
Help us improve. Please let us know the company, where you were asked this question :
Junit 2016112211:18:43
Q14.Whatistheuseof@Beforeannotation?
Ans. When executing tests it is common that multiple tests need similar objects to be created
beforetheycanrun.@beforespecifiesamethodthatprovidethatinitializationforthesetofUnit
Tests.
Help us improve. Please let us know the company, where you were asked this question :
Like Discuss
Testing 2016120716:13:30
Q15.Haveyouevertriedmockingstaticmethods?
Ans. Yes, that can be done using Power Mock. Mockito doesnt provide a way to mock static
methods.
Help us improve. Please let us know the company, where you were asked this question :
Like Discuss Mockitojunitpowermock
Junit 2017050913:34:52
Q16. Does a Junit without any assertions makes any
sense?
Ans. Yes, If we are testing a code segment to check if throws / doesn't throw an exception.
Moreoverwhiletestingvoidmethods,wemayjustverifyandnotuseassert.
Help us improve. Please let us know the company, where you were asked this question :
Junit 2017051716:50:18
Q17.What are the benefits of assertThat over assert in
Junits?
Ans. assertThat is introduced with Junit4 and offers many advatanges over assert. Messages are
more explanatory, offer better type safety and are more readable. Moreover hamcrest library is
portableasitcanusedbothwithjunitandTestNG.MoreoverassertThatprovidesflexibilityasthe
same method can be used for assert , assertEquals,assertTrue etc through the use of matcher
methods.
Help us improve. Please let us know the company, where you were asked this question :
Junit 2017051716:52:13
Q18.Canyounamefewmatchersthatcanbeusedwith
hamcrestassertThatmethod?
Ans.is
not
equals
anyOf
hasSize
Help us improve. Please let us know the company, where you were asked this question :
beforeexecutingsetoftests?
a.@Test
b.@Ignore
c.@After
d.@Before
Ans.d.@Before
JavaUnitTestingInterview
Questions
byAjiteshKumar Aug.06,14DevOpsZone
DownloadTheDevOpsJourneyFromWaterfalltoContinuousDeliveryto
learnlearnabouttheimportanceofintegratingautomatedtestingintotheDevOps
workflow,broughttoyouinpartnershipwithSauceLabs.
Thearticlepresentssomeofthefrequentlyaskedinterviewquestionsinrelation
withunittestingwithJavacode.Pleasesuggestotherquestionstthatyoucame
acrossandIshallincludeinthelistbelow.
1.Whatisunittesting?Whichunittestingframeworkdidyouuse?Whatare
someofthecommonJavaunittestingframeworks?
Ans:ReadthedefinitionofUnittestingonWikipediapageforunittesting.
Simplyspeaking,unittestingisabouttestingablockofcodeinisolation.
TherearetwopopularunittestingframeworkinJavanamedasJunit,TestNG.
2.InSDLC,Whenistherighttimetostartwritingunittests?
Ans:TestalongifnottestdrivenWritingunitteststowardsendisnotvery
effective.Testalongtechniquerecommendsdeveloperstowritetheunittests
astheygowiththeirdevelopment.
3.WithJunit4,dowestillneedmethodssuchassetUpandtearDown?
Ans:No.Thisistakencarewithhelpof@Beforeand@Afterannotations
respectively
4.Whatdofollowingjunittestannotationsmean?
Ans:FollowingisalistoffrequentlyusedJUnit4annotations:@Test(@Test
identifiesatestmethod)
@Before(Ans:@BeforemethodwillexecutebeforeeveryJUnit4test)@After
(Ans:@AftermethodwillexecuteaftereveryJUnit4test)@BeforeClass(Ans:
@BeforeClassmethodwillbeexecutedbeforeJUnittestforaClass
starts)@AfterClass(Ans:@AfterClassmethodwillbeexecutedafterJUnittest
foraClassiscompleted)@Ignore(@Ignoremethodwillnotbeexecuted)
5.Howdoonedoexceptionhandlingunittestsusing@Testannotation?
Ans:@Test(expected={exceptionclass}.Forexample:
@Test(expected=IllegalArgumentException.class)
6.Writeasampleunittestingmethodfortestingexceptionnamedas
IndexOutOfBoundsExceptionwhenworkingwithArrayList?
@Test(expected=IndexOutOfBoundsException.class)
publicvoidoutOfBounds(){
newArrayList<Object>().get(1);
}
7.Writeasampleunittestingmethodfortestingtimeout?
@Test(timeout=100)
publicvoidinfinity(){
while(true);
}
8.Whatisunittestingmethodnamingconventionthatyoufollow?
Ans:Unittestsnameshouldactlikethedocumentationgivingaclearideaon
whatfunctionalityistested.Therearevarioustechniquesthatcouldbeusedto
nameunittests.Someofthemarefollowing:GivenWhenThen..or
ShouldThenetc.
9.Whatarecalledastestsmellsinrelationwithunittesting?
Ans:Followingcouldbetermedastestsmells:Multipleassertionswithinone
unittest,longrunningunittestsetc
10.Whataretop23advantagesofwritingunittests?
Ans:Designtestability,Codetestability,Codemaintainabilityasgoodunit
testsenforcesOOprinciplessuchasSingleResponsitbilityetcwhichenables
peopleavoidcodesmellssuchaslongclasses,longmethods,largeconditionals
etc.
11.Whataretop23characteristicsofHardtotestcode?
Ans:Longmethods,Longconditionals,mixingconcerns,bulkyconstructors
12.Whatismocking&stubbing?Whatarekeydifferencesbetweenthem?Didyou
useanymockingframework?
Ans:ReaddetailsonWhatisdifferencebetweenstubbingandmockingon
thispage..TherearevariousdifferentJavamockingframeworksuchas
Mockito,EasyMocketc.
13.Whataretop23advantagesofmocking?
Ans:1.Verifyinteractions2.Testtheblockofcodeinisolation
14.Howiscodecyclomaticcomplexityrelatedtounittests?
Ans:Ascodecyclomaticcomplexityisdeterminedbasedonnumberof
decisionpointswithinthecodeandhenceexecutionpaths,highercyclomatic
complexitymakesitdifficulttoattainachievetest/codecoverage.
15.Whatiscodecoverage?Howisitmeasured?NamesomeJUnitcodecoverage
tools?Ans:Cobertura,EclEmma
16.Namesomecodesmellswhichmakesithardtoachievehighcodecoverage?
Ans:Longmethod,Largeconditionals
17.Whatistestdrivendevelopment(TDD)?
Ans:ReadthedetailsonWikipediapageforTDD.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question1of24
5points
WhyNotJustUseaDebuggerforUnitTesting?
Automatedunittestingrequiresextratimetosetupinitially.Butitwillsaveyourtime,ifyourcoderequires
changesmanytimesinthefuture.Adebuggerisdesignedformanualdebuggingandmanualunittesting,notfor
automatedunittesting.JUnitisdesignedforautomatedunittesting.
1. False
2. True
Correct
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question2of24
5points
WhatisJUnit?
JUnitisasoftwaretestingframeworkforunittesting,openSourceSoftwaremaintainedbytheJUnit.org
community.JUnitwasoriginallywrittenbyErichGammaandKentBeck.
Testrunnersforrunningtests
Testfixturesforsharingcommontestdata
Assertionsfortestingexpectedresults
1. False
2. True
Incorrect
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question3of24
5points
DoYouHaveToWriteaTestforEverything?
Youhavetowriteatestforeverythingthatcouldreasonablybreak.KeepinmindNullPointerExceptionwhich
occursmaximum.
Bepracticalandmaximizeyourtestinginvestment.Rememberthatinvestmentsintestingareequalinvestments
indesign.Ifdefectsaren\tbeingreportedandyourdesignrespondswelltochange,thenyou\reprobably
testingenough.Ifyou\respendingalotoftimefixingdefectsandyourdesignisdifficulttogrow,youshould
writemoretests.
Ifsomethingisdifficulttotest,it\susuallyanopportunityforadesignimprovement.Looktoimprovethe
designsothatit\seasiertotest,andbydoingsoabetterdesignwillusuallyemerge.
1. False
2. True
Incorrect
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question4of24
5points
HowToRunaJUnitTestClass?
AJUnittestclassusuallycontainsanumberoftestmethods.YoucanrunalltestmethodsinaJUnittestclass
withtheJUnitCorerunnerclass.Forexample,torunthetestclassLoginTest.javadescribedpreviously,you
shoulddothis:
javacp.
junit4.4.jarorg.junit.runner.JUnitCoreLoginTest
JUnitversion4.4
Time:0.015
OK(1test)
Thisoutputsaysthat1testsperformedandpassed.Thesameyoucanperformbyexecutingbuild.xmlalso.
1. False
2. True
Incorrect
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question5of24
5points
HowToCreateTestClassinEclipse?
ToCreateTestClassinEclipseyoumust:
1.SelectFileNewJUnitTestCase.
2.Selectthearrowofthebuttonintheupperleftofthetoolbar.SelectJUnitTestCase.
3.RightclickonapackageinthePackageExplorerviewintheJavaPerspective,andselectJUnitTestCase.
4.Clickonthearrowoftheiconinthetoolbar.SelectJUnitTestCase.
5.YoucancreateanormalJavaclassasshownintheEclipsetutorial,butincludejunit.framework.TestCaseas
thesuperclassofthetestclassyouarecreating.
1. True
2. False
Correct
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question6of24
5points
HowDoYouTestaprotectedMethod?
Asamethodisdeclaredas\protected\,itcanonlybeaccessedwithinthesamepackagewheretheclassis
defined.Totesta\protected\methodofatargetclass,youneedtodefineyourtestclassinthesamepackage
asthetargetclass.
1. True
2. False
Correct
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question7of24
5points
HowToWriteaJUnitTestMethod?
IfyouwanttowriteaJUnitTestMethodyouneedtomarkthemethodasaJUnittestmethodwiththeJUnit
annotation:@org.junit.Test.
*AJUnittestmethodmustbea\public\method.Thisallowstherunnerclasstoaccessthismethod.
*AJUnittestmethodmustbea\void\method.Therunnerclassdoesnotcheckanyreturnvalues.
*AJUnittestshouldperformoneJUnitassertioncallinganorg.junit.Assert.assertXXX()method.
HereisasimpleJUnittestmethod:
importorg.junit.*
@TestpublicvoidtestLogin(){
Stringusername=\withoutbook\
Assert.assertEquals(\withoutbook\,username)
}
1. False
2. True
Incorrect
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question8of24
5points
HowDoYouTestaprivateMethod?
Whenamethodisdeclaredas\private\,itcanonlybeaccessedwithinthesameclass.Sothereisnowayto
testa\private\methodofatargetclassfromanytestclass.
Toresolvethisproblem,youhavetoperformunittestingmanually.Oryouhavetochangeyourmethodfrom
\private\to\protected\.
Orifitisnotpossibletoconvertanyoftheaboveways,youcantestprivatemethodbyusingPowerMock
partialMock.
1. False
2. True
Incorrect
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question9of24
5points
DoYouNeedtoWriteaTestClassforEveryClassThatNeedtoBeTested?
Thereisnoneedtowriteonetestclassforeacheveryclassthatneedtobetested.Onetestclasscancontain
manytestsformanytesttargetclasses.Thetechnicalanswerisno.
Youshoulddesignonetestclasspertesttargetclassforlowlevelbasictests.Thismakesyourtestclassesmuch
easiertomanageandmaintain.Youshouldwriteseparatetestclassesforhighlevelteststhatrequiresmultiple
targetclassesworkingtogether.Thepracticalanswerisyes.
1. True
2. False
Correct
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question10of24
5points
HowToWriteaSimpleJUnitTestClass?
YoushouldbeabletowritethissimpleJUnittestclasswithonetestmethod:
importorg.junit.*
publicclassLoginTest
{
@TestpublicvoidtestLogin()
{
Stringusername=\\\withoutbook\\\
Assert.assertEquals(\\\withoutbook\\\,username)
}
}
HerefirstargumentinassertEqualsistheknownparameterwhichshouldbeequaltousername.Ifbotharesame
itwillsendmetrueandifbotharenotequalsendsmefalse.
1. False
2. True
Incorrect
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question11of24
5points
WhenShouldUnitTestsShouldBeWrittenInDevelopmentCycle?
YoushouldwriteunittestbeforewritingthecodeifyouareaTDD(TestDrivenDevelopment)believer.Test
firstprogrammingispracticedbyonlywritingnewcodewhenanautomatedtestisfailing.
Goodteststellyouhowtobestdesignthesystemforitsintendeduse.Theyeffectivelycommunicateinan
executableformathowtousethesoftware.Theyalsopreventtendenciestooverbuildthesystembasedon
speculation.Whenallthetestspass,youknowyou\redone!
Wheneveracustomertestfailsorabugisreported,firstwritethenecessaryunittest(s)toexposethebug(s),
thenfixthem.Thismakesitalmostimpossibleforthatparticularbugtoresurfacelater.Testdrivendevelopment
isgainingmomentumthesedayscomparedtowritingtestsafterthecode.
1. False
2. True
Incorrect
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question12of24
5points
WhyNotJustWriteamain()MethodforUnitTesting?
Youcanwriteamain()methodineachclassthatneedstobetestedforunittesting.Inthemain()method,you
couldcreatetestobjectoftheclassitself,andwritesometeststotestitsmethods.However,thisisnota
recommendedapproachbecauseofthefollowingpoints:
*Yourclasseswillbeclutteredwithtestcodeinmainmethod.Allthosetestcodeswillbepackagedintothe
finalproduct.
*Ifyouhavealotsofclassestotest,youneedtorunthemain()methodofeveryclass.Thisrequiressomeextra
codingeffort.
*IfyouwantthetestresultstobedisplayedinaGUI,youwillhavetowritecodeforthatGUI.
*IfyouwanttologtheresultsoftestsinHTMLformatortextformat,youwillhavetowriteadditionalcode.
*Ifonemethodcallfails,nextmethodcallswon\tbeexecuted.Youwillhavetoworkaroundthis.
1. False
2. True
Incorrect
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question13of24
5points
Youshouldrunallyourunittestsasoftenaspossible,ideallyeverytimethecodeischanged.Makesureallyour
unittestsalwaysrunat100%.Frequenttestinggivesyouconfidencethatyourchangesdidn\tbreakanything
andgenerallylowersthestressofprogramminginthedark.
Forlargersystems,youmayjustrunspecifictestsuitesthatarerelevanttothecodeyou\reworkingon.Runall
youracceptance,integration,stress,andunittestsatleastonceperday.
1. True
2. False
Correct
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question14of24
5points
HowDoYouTestaMethodThatDoesnotReturnAnything?
ToTestaMethodThatDoesnotReturnAnythingyouneedtofollowthebelowlogics:
*Ifamethodisnotreturninganythingthroughthe\return\statement(voidmethod),itmayreturndata
throughitsarguments.Inthiscase,youcantestthedatareturnedinanyargument.
*Elseifamethodisnotreturninganydatathroughitsarguments,itmaychangevaluesofitsinstancevariables.
Inthiscase,youcantestchangesofanyinstancevariables.
*Elseifamethodisnotchanginganyinstancevariable,itmaychangevaluesofitsclassvariables.Inthiscase,
youcantestchangesofanyclassvariables.
*Elseifamethodisnotchanginganyclassvariable,itmaychangeexternalresources.Inthiscase,youcantest
changesofanyexternalresources.
*Elseifamethodisnotchanginganyexternalresources,itmayjustdoingnothingbutholdingthethreadina
waitingstatus.Inthiscase,youcantestthiswaitingcondition.
*Elseifamethodisnotholdingthethreadinwaitingstatus,thenthismethodisreallydoingnothing.Inthis
case,thereisnoneedtotestthismethod!
1. False
2. True
Incorrect
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question15of24
5points
WhyNotJustUseaDebuggerforUnitTesting?
Automatedunittestingrequiresextratimetosetupinitially.Butitwillsaveyourtime,ifyourcoderequires
changesmanytimesinthefuture.Adebuggerisdesignedformanualdebuggingandmanualunittesting,notfor
automatedunittesting.JUnitisdesignedforautomatedunittesting.
1. True
2. False
Correct
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question16of24
5points
WhyNotJustUseSystem.out.println()forUnitTesting?
WedontuseSystem.out.println()forUnitTestingbecauseifweadddebugstatementsintocode,itisalowtech
methodfordebuggingit.Itusuallyrequiresthatoutputbescannedmanuallyeverytimetheprogramisrunto
ensurethatthecodeisdoingwhat\sexpected.
ItgenerallytakeslesstimeinthelongruntocodifyexpectationsintheformofanautomatedJUnittestthat
retainsitsvalueovertime.Ifit\sdifficulttowriteatesttoassertexpectations,thetestsmaybetellingyouthat
shorterandmorecohesivemethodswouldimproveyourdesign.
1. False
2. True
Incorrect
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question17of24
5points
HowtocreateaTestSuiteusingJUnitinEclipse?
TherearefourwaystocreateaJUnittestsuiteclassinEclipsewithJUnitplugin:org.junit_3.8.1.First,select
thedirectory(usuallyunittests)thatyouwishtocreatethetestsuiteclassin.
1.SelectFile>New>Other>Java>JUnit>JUnitTestSuite.
2.Selectthearrowofthebuttonintheupperleftofthetoolbar.SelectOther>Java>JUnit>JUnitTest
Suite,
3.RightclickonapackageinthePackageExplorerviewintheJavaPerspective,andselectOther>Java>
JUnit>JUnitTestSuite,
4.YoucancreateanormalJavaclassasshownintheEclipsetutorial,butincludejunit.framework.TestSuiteas
thesuperclassofthetestclassyouarecreating.
1. False
2. True
Incorrect
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question18of24
5points
WhatCLASSPATHSettingsAreNeededtoRunJUnit?
YourunyourJUnittestsfromacommandline,fromanIDE,orfrom\ant\,youmustdefineyour
CLASSPATHsettingscorrectly.HereiswhatrecommendedbytheJUnitFAQwithsomeminorchanges:
TorunyourJUnittests,you\llneedthefollowingelemementsinyourCLASSPATH:
*TheJUnitJARfileshouldbethere.
*LocationofyourJUnittestclasses.
*Locationofclassestobetested.
*JARfilesofclasslibrariesthatarerequiredbyclassestobetested.
IffoundNoClassDefFoundErrorinyourtestresults,thensomethingismissingfromyourCLASSPATH.
IfyouarerunningyourJUnittestsfromacommandlineonaWindowssystem:
setCLASSPATH=c:\\A\\junit4.4.jarc:\\B\\test_classes
c:\\B\\target_classes
IfyouarerunningyourJUnittestsfromacommandlineonaUnix(bash)system:
exportCLASSPATH=/A/junit4.4.jar:/B/test_classes:
/C/target_classes:
1. False
2. True
Incorrect
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question19of24
5points
WhoShouldUseJUnit?
JUnitismostlyusedbydevelopersfortestingtheirwrittencode.JUnitisdesignedforunittesting,which
isreallyacodingprocess,notatestingprocess.ButmanytestersorQAengineers,arealsorequiredtouse
JUnitforunittesting.
1. False
2. True
Incorrect
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question20of24
5points
PleaseExplaintheLifeCycleofaJUnit4.4TestClass?
AJUnit4.4testclasscontainsa@Beforemethod,an@Aftermethodandmultiple@testmethods.When
callingatestrunnertorunthistestclass,therunnerwillexecutethosemethodsinaspecificordergivingthetest
classanexecutionlifecyclelikethis:
@Before
@TestXXX1
@After
@Before
@TestXXX2
@After
1. False
2. True
Incorrect
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question21of24
5points
CanYouExplaintheLifeCycleofaJUnit3.8TestCaseClass?
LifeCycleofaJUnit3.8testcaseclasscontainsasetUp()method,atearDown()methodandmultipletestXXX()
methods.Whencallingatestrunnertorunthistestclass,therunnerwillexecutethosemethodsinaspecific
ordergivingthetestcaseclassanexecutionlifecyclelikethis:
setUp()
testXXX1()
tearDown()
setUp()
testXXX2()
tearDown()
1. False
2. True
Incorrect
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question22of24
5points
HowToCompileaJUnitTestClass?
AsJUnitcodeiswritteninjava,compilingaJUnittestclassislikecompilinganyotherJavaclasses.Theonly
thingyouneedwatchoutisthattheJUnitJARfilemustbeincludedintheclasspathlikejunit.jaretc.For
example,tocompilethetestclassLoginTest.javadescribedpreviously,youshoulddothis:
javaccpjunit4.4.jarLoginTest.java
anditwillcreate.classfile.
LoginTest.class
Thecompilationisok,ifyouseetheLoginTest.classfile.
1. False
2. True
Incorrect
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question23of24
5points
UnderWhatConditionsShouldYouTestset()andget()Methods?
Weshouldtestset()andget()Methodsbecausetargetareasthatmightbreak.set()andget()methodsonsimple
datatypesareunlikelytobreak.Sononeedtotestthem.
set()andget()methodsoncomplexdatatypesarelikelytobreak.Soyoushouldtestthem.
1. False
2. True
Incorrect
Next
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.
SQASolution
SQASolutionSQASolutionInterviewQuestionsJUnitInterviewQuizforQAEngineers
HOME QA SERVICES TRAINING DELIVERY MODELS INDUSTRIES CAREERS
JUnitInterviewQuizforQAEngineers
COMPANY
byadminonMay14,2014
JUnitInterviewQuestions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24
Answered Review
Reviewquestion Quizsummary
Question24of24
5points
HowDoIRunJUnitTestsfromCommandWindow?
YouneedtocheckthefollowinglisttorunJUnittestsfromacommandwindow:
1.MakesurethatJDKisinstalledandthe\java\commandprogramisaccessiblethroughthePATHsetting.
Type\javaversion\atthecommandprompt,youshouldseetheJVMreportsyoubacktheversionstring.
2.MakesurethattheCLASSPATHisdefinedasshowninthepreviousquestion.
3.InvoketheJUnitrunnerbyenteringthefollowingcommand:
javaorg.junit.runner.JUnitCore
1. False
2. True
Incorrect
Quizsummary
#SQASolution
Taggedas:JUnitInterviewQuiz,JUnitInterviewQuiz[WpProQuiz4]
Previouspost:LogicalQuiz
Nextpost:TestNGInterviewQuestions
Search
Tosearch,typeandhitenter
HAVEQUESTIONS?
8887891482
Like 90peoplelikethis.SignUptosee
whatyourfriendslike.
"...oneoftheverybesttestingteams..."
QAManager,PharmaCompany
"...providingdifficulttofindQAresources..."
ProjectManager,eMarketing
"...alwaysverythorough..."
CTO,GovernmentAgency
"WhenourQAteamsareoverextended,SQASolutionprovidesuswithacosteffectivestrategythat
works.WenowrelyonSQASolutionforeverymajorrelease."
AlexM.,Fortune100FinancialInstitution
Contactusformorereferences
09/04/2015QAResumePreparationGuidelines
05/28/2015QASoftwareTestingResumeReviewsessions
03/02/2015ClassDemoandQABootcampOpenHouse
02/16/2015TESTERS:TellYourStoryatSoftwareQAandTestersMeetup
10/21/2014RoundTable:CareerDevelopmentforSoftwareTestersandQA
CaseStudy:MobileAppTestingonRealHandsets
CaseStudy:ReleaseandConfigurationManagement
CaseStudy:ReleaseEngineering
interested
SoftwareQualityAssurance(QA)EngineerSkills
Interested
QAResumeServices
AutomatedTestGenerationUsingConcolicTesting
Tags
Home/Sitemap/PoliciesandTerms/ContactUs/Careers/Services/NDA/Brochure
Copyright2013SQASolution.Allrightsreserved.