All Questions
15 questions
3
votes
3
answers
3k
views
Combine two jUnit test cases into one
I have the following two junit test cases:
@Test(expected=NullPointerException.class,timeout=2000)
public void X1()
{
abc.xyz(null);
fail("Car xyz() should throw NullPointerException when ...
0
votes
1
answer
970
views
test case not covering in cobertura
public class MyUtil {
public static Properties loadProperties() throws Exception {
Properties prop = new Properties();
InputStream inputStream = MyUtil.class.getClassLoader()....
-5
votes
3
answers
654
views
JUnit 4 Test Case [closed]
I need help on creating JUnit 4 Test Case for this code.
public static int computeValue(int x, int y, int z)
{
int value = 0;
if (x == y)
value = x + 1;
else if ((x > y) &&...
3
votes
2
answers
15k
views
How to test the method that reads the data from the excel file in java?
The above picture shows the excel file containing the Facebook data.
The class FacebookDataExtraction reads the data from the Excel file and stores the data as list of row objects as shown in the ...
1
vote
2
answers
576
views
Test class for Abstract class with no default constructor and private method?
I have got a problem in my project and I'm putting up my problem in some sample example.
package com.sample.code;
public abstract class AbstractClass {
public String var1;
//in this class ...
4
votes
4
answers
2k
views
Common @before and @after for test classes in junit
Is it possible to have a common @Before and @After fixtures that can be used across multiple test classes?
I have segregated the tests (into classes) based on modules (Inventory, Sales, Purchase etc.)...
2
votes
1
answer
5k
views
Junit : Cannot test header information in the response
I am new to JUnit. I am trying to write a test case for java filter. Following is the filter code -
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, ...
3
votes
1
answer
2k
views
Launch Suite classes using another Suite class
I would like to launch some Suite classes with JUnit 4, using another Suite class.
I have the following test suite for one package:
package com.manuel.package1;
import org.junit.runner.RunWith;
...
0
votes
2
answers
4k
views
How to write a junit testcase for a void method that creates a new object
public class SupportController{
public void disableUserAccount(String username) throws Exception {
UserAccount userAccount =
new UserAccount(Constants.SYSTEM, Constants....
2
votes
1
answer
1k
views
Junit4 Test Suite - Looping and adding test cases dynamically from test suite
I have an XML file with many models.
I'm parsing this XML file in Test Suite and reading each model.
For each model, I want to execute specific list of test cases.
That means, inside a FOR loop in ...
0
votes
1
answer
525
views
Junit4 test case for Thread
Hi I am Trying to write Junit test case for this because i cant return anything here to catch and test assertrue(....) in my test case. SendMailTLS is a separate classs(without main) which sends mail ...
0
votes
1
answer
1k
views
How to print the value within the method in testcase?
I need to print the value within the method using the test case.
My code is:
public void testgetAllRatingElementsWeekNo() throws Exception
{
String METHOD_NAME = "testgetAllRatingElementsWeekNo";
...
89
votes
6
answers
61k
views
Test cases in inner classes with JUnit
I read about Structuring Unit Tests with having a test class per class and an inner class per method. Figured that seemed like a handy way to organize the tests, so I tried it in our Java project. ...
1
vote
2
answers
1k
views
Junit 3 to JUnit 4 conversion
I had the following version of a test in JUnit 3, and I tried converting it into JUnit 4, with no success. The idea is to have a base test case, that does the actual test of an interface, say Service ...
0
votes
2
answers
873
views
how to get Tests run count on running same testCase for multiple times with different data
hi i want to run same testcase for multiple times with different data
for example if i run the same testcase for 3 times with different data it should show
Tests run: 3,failures : 0
when i tried ...