Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Which methods cannot be tested by JUnit? Explain why the answer is correct and rest options are not. a) public methods b) private methods c)

Which methods cannot be tested by JUnit? Explain why the answer is correct and rest options are not.

a) public methods

b) private methods

c) protected methods

d) any method can be tested with Junit test

sol33:

JUnit is a testing framework for Java programming language that can be used to test different types of methods in Java classes. However, there are certain types of methods that cannot be tested by JUnit.

The answer is (b) private methods. JUnit can only test public methods in a Java class. Private methods are inaccessible from outside the class, including JUnit test cases. In order to test a private method, it must be changed to public, or tested indirectly through public methods that call it.

Therefore, options (a) public methods, (c) protected methods, and (d) any method can be tested with JUnit test are all correct as JUnit can test public and protected methods, as well as any method that can be accessed by a public or protected method.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

A First Course in Differential Equations with Modeling Applications

Authors: Dennis G. Zill

11th edition

1305965728, 978-1305965720

More Books

Students also viewed these Programming questions