CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.




Get it now !!
Send your Resume to 6000 Companies
Code Coverage Interview Questions & Answers - Learning Mode
COOLINTERVIEW.COM TESTING GLOSSARY INTERVIEW QUESTIONS CODE COVERAGE INTERVIEW QUESTIONS QUESTIONS & ANSWERS - LEARNING MODE

Code Coverage Interview Questions & Answers - Learning Mode

Code coverage is a measure used in software testing. It describes the degree to which the source code of a program has been tested. It is a form of testing that inspects the code directly and is therefore a form of white box testing. In computer science, code coverage is a measure used to describe the degree to which the source code of a program is tested by a particular test suite.

Try Code Coverage Interview Questions & Answers - Exam Mode

1

Sort By : Latest First | Oldest First | By Rating

Code Coverage Interview Questions & Answers - Learning Mode
Try Code Coverage Interview Questions & Answers - Exam Mode
Question: I'm trying to get a coverage report mailed to the team as shown in your example, but I keep getting "[mail] Failed to send email". How do I fix this?

Answer: The Ant <mail> task depends on external libraries that are not included in the Ant distribution. You need to install the following jars in ANT_HOME/lib, both freely available from Sun:
1. mail.jar - from the JavaMail API (http://java.sun.com/products/javamail/)
2. activation.jar - from the JavaBeans Activation Framework (http://java.sun.com/products/javabeans/jaf/index.jsp)
You should also check the details of your local SMTP server with your SysAdmin. It may help to specify these Source: CoolInterview.com
Question: When using Clover from Ant, why do I get "Compiler Adapter 'org.apache.tools.ant.taskdefs.CloverCompilerAdapter' can't be found." or similar?

Answer: You need to install Clover in Ant's classpath. Depending on what version of Ant you are using, there are several options to do this. See Installation Options Source: CoolInterview.com
Question: What are the limitations of Code Coverage?

Answer: Code Coverage is not a "silver bullet" of software quality, and 100% coverage is no guarantee of a bug free application. You can infer a certain level of quality in your tests based on their coverage, but you still need to be writing meaningful tests.
As with any metric, developers and project management should be careful not to over-emphasize coverage, because this can drive developers to write unit tests that just increase coverage, at the cost of actually testing the application meaningfu Source: CoolInterview.com
Question: When generating some report types on my unix server with no XServer, I get an exception "Can't connect to X11 server" or similar.

Answer: This is a limitation of the Java implementation on Unix. Prior to JDK 1.4, the java graphics toolkit (AWT) requires the presence of an XServer, even in the case where no "on-screen" graphics are rendered. With JDK1.4, you can set the System property java.awt.headless=true to avoid this problem. When running Ant, this is most easily achieved by using the ANT_OPTS environment variable:
export ANT_OPTS=-Djava.awt.headless=true
When running your code outside Ant, you may also need to set this Source: CoolInterview.com
Question: Why do I get 0% coverage when I run my tests and then a reporter from the same instance of Ant?

Answer: This occurs because Clover hasn't had a chance to flush coverage data out to disk. By default Clover flushes coverage data only at JVM shutdown or when explicitly directed to (using a inline directive). The simplest thing to do is to use the fork="true" attribute when running your tests. The tests will be then run in their own JVM, and the coverage data will be flushed when the that JVM exits. Alternatively, you can use interval-based flushing by changing the Flush Policy. Source: CoolInterview.com
Question: Why does Clover instrument classes I have excluded using the <exclude> element of the <clover-setup> task?

Answer: There are two possible causes.
1. Cascading build files:
Clover uses Ant patternsets to manage the includes and excludes specified in the clover-setup task. By default Ant does not pass these patternsets to the sub-builds. If you are using a master-build/sub-build arrangement, with compilation occuring in the sub-builds and <clover-setup> done in the master-build, you will need to explicitly pass these patternsets as references:
<ant ...>
<reference refid="clove Source: CoolInterview.com
Question: Why the name "Clover"?

Answer: Clover is actually a shortened version of the tool's original name, "Cover Lover", from the nick name that the tool's author gained while writing Clover ("Mr Cover Lover"). Source: CoolInterview.com
Question: When using Clover, why do I get a java.lang.NoClassDefFoundError when I run my code?

Answer: This probably indicates that you do not have clover.jar in your runtime classpath. Source: CoolInterview.com
Question: Does Clover support the new language features in JDK1.5?

Answer: Clover fully supports all JDK1.5 language features. Source: CoolInterview.com
Question: Where did Clover originally come from?

Answer: Clover was originally developed at Cenqua as an internal tool to support development of large J2EE applications. Existing tools were found to be too cumbersome to integrate with complex build systems and often required specialized development and/or runtime environments that were not compatible with target J2EE Containers. Another feature that we found lacking in other tools was simple, source-level coverage reporting - the kind that is most useful to developers. Source: CoolInterview.com
Question: For some statements in my code Clover reports "No Coverage information gathered for this expression". What does that mean?

Answer: Clover will not measure coverage of a conditional expression if it contains an assignment operator. In practice we have found this only a minor limitation. To understand why Clover has this limitation, consider the following (very contrived) code fragment:
1 public int foo(int i) {
2 int j;
3 if ((j = i) == 1) {
4 return j;
5 }
6 return 0;
7 }

at (2) the variable "j" is declared but not initialised.
at (3) "j" is assigned to inside the e Source: CoolInterview.com
Question: How are the Clover coverage percentages calculated?

Answer: The "total" coverage percentage of a class (or file, package, project) is provided as a quick guide to how well the class is covered - and to allow ranking of classes. The Total Percentage Coverage (TPC) is calculated using the formula:
TPC = (CT + CF + SC + MC)/(2*C + S + M)

where

CT - conditionals that evaluated to "true" at least once
CF - conditionals that evaluated to "false" at least once
SC - statements covered
MC - methods entered

C - total number Source: CoolInterview.com
Question: Why do I get an java.lang.OutOfMemoryError when compiling with Clover turned on?

Answer: Instrumenting with Clover increases the amount of memory that the compiler requires in order to compile. To solve this problem, you need to give the compiler more memory. Increasing the memory available to the compiler depends on how you are launching the compiler:
If you are using the "in-process" compiler (the <javac> task with the "fork" attribute set to false), you will need to give Ant itself more memory to play with. To do this, use the ANT_OPTS environment variable to set the hea Source: CoolInterview.com
Question: What is Code Coverage Analysis?

Answer: Code Coverage Analysis is the process of discovering code within a program that is not being exercised by test cases. This information can then be used to improve the test suite, either by adding tests or modifying existing tests to increase coverage.
Code Coverage Analysis shines a light on the quality of your unit testing. It enables developers to quickly and easily improve the quality of their unit tests which ultimately leads to improved quality of the software under development.
Source: CoolInterview.com
Question: Why does Clover use Source Code Instrumentation?

Answer: Source code instrumentation is the most powerful, flexible and accurate way to provide code coverage analysis. The following table compares different methods of obtaining code coverage and their relative benefits:
Possible feature JVMDI/PI Bytecode instrumentation Source code instrumentation
gathers method coverage yes yes yes
gathers statement coverage line only indirectly yes
gathers branch coverage indirectly indirectly yes
can work without source yes yes no
requires se Source: CoolInterview.com
Question: Does Clover work with JUnit4 and TestNG?

Answer: Clover is fully compatible with JUnit4 and TestNG. Source: CoolInterview.com
Question: Does Clover depend on JUnit?

Answer: Clover has no dependence on JUnit. We mention it frequently in our documentation only because of JUnit's widespread use in the Java dev community. You can certainly instrument your code and run it however you like; Clover will still record coverage which can then be used to generate reports. Source: CoolInterview.com
Question: Will Clover integrate with my IDE?

Answer: Clover provides integrated plugins for IntelliJ IDEA 4.x and 5.x, NetBeans, and Eclipse, JBuilder and JDeveloper. Clover should also work happily with any IDE that provides integration with the Ant build tool. Source: CoolInterview.com
Question: What 3rd Party libraries does Clover utilise?

Answer: Clover makes use of the following excellent 3rd party libraries:
Jakarta Velocity 1.2 Templating engine used for Html report generation.
Antlr 2.7.1
A public domain parser generator.
iText 0.96
Library for generating PDF documents.
Jakarta Ant
The Ant build system.
Note
To prevent library version mismatches, all of these libraries have been obfuscated and/or repackaged and included in the clover jar. We do this to prevent pain for users that may use different versions Source: CoolInterview.com

1



India News Network
Latest 20 Questions
Payment of time- barred debt is: (a) Valid (b) Void (c) Illegal (d) Voidable
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
Cache = 0 Seconds