Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
0 answers
52 views

How to run Junit Testsuite in Real time project

I made a test class A and B. Those test classes run separately fine. But if I try to run all in single Test Suite, I get the below error: java.lang.Exception: class 'com.test.dev.Commonflow' (possibly ...
Aishu's user avatar
  • 1
0 votes
1 answer
123 views

junit 4 testcases and test suites in the same folder

I have some JUnit 4 test cases and test suites that are in the same directory. When I run these from eclipse using a right-click on the top level test directory, the all of the test cases that do not ...
Ray Tayek's user avatar
  • 10k
1 vote
1 answer
5k views

How to write junit cases for @Bean for configuration classes

I have the below method in the @Configuration class and I need to write JUnit for this. Can anyone please guide me to achieve the JUnit test case? @Bean @Profile({"!test & !local"}) @...
Sdcoder's user avatar
  • 43
0 votes
1 answer
356 views

Junit 4 extend TestCase vs using combo of @Before/@After/@Test

With Junit 4 I am seeing that there are two ways of getting fixtures setup/teardown: Decorate setup/tearDown methods with @Before and @After respectively Extend TestCase and override setUp/tearDown ...
sshekhar1980's user avatar
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 ...
NoobCoder's user avatar
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()....
Extreme 's user avatar
  • 3,379
-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) &&...
Syy's user avatar
  • 11
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 ...
ShridharBavannawar's user avatar
0 votes
0 answers
38 views

Changing sequence of JUnit gives random errors

I have a set of JUnit test cases in various packages. When I put them together in a test suite in a sequence it passes all the test cases. However, when I change their sequence the ones that have @...
Humpty Dumpty's user avatar
0 votes
0 answers
621 views

junit 4 all pairwise permutations of test methods

i have a test case that has n test methods, one of the test methods fails when the test case is run. and this failing test method succeeds when run by itself. i would like to dynamically (at run time)...
Ray Tayek's user avatar
  • 10k
0 votes
0 answers
110 views

How to write test case for the given code using powermockito

I just want to know if i have a code like - public class A { static String b = "hello"; public static String a() { String b = b(); String d = d(b); String e = e(d, b); return e; }...
u12345's user avatar
  • 389
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 ...
kumar ch's user avatar
1 vote
1 answer
58 views

J-unit Testing - Writing Test Case of a Class which is extended by dialogue or Asynctask?

I am new to testing phase ,I'd like to write test case of a class which is extended by dialogue or Asynctask ,but i am not able to access the stuff of dialogue class in my test case . rather i have ...
Shani Goriwal's user avatar
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.)...
Krishna Sarma's user avatar
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, ...
user3627913's user avatar
0 votes
1 answer
133 views

The order of the test methods in a Test Suite by JUnit4Spring

Is the order of the test methods in a Test Suite by JUnit4Spring reliable? Otherwise, is there anyway to enforce the order? Thank you a lot.
user3169231's user avatar
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; ...
Manuelarte's user avatar
  • 1,796
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....
user2634532's user avatar
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 ...
Arun Suresh's user avatar
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 ...
HkFreaKuser1673718's user avatar
1 vote
0 answers
799 views

Junit test cases for hibernate

I have developed a web project(struts2+hibernate) for which i need to do code coverage.I dont know how to write junit test cases for this Hibernate part.Can anyone suggest me idea.i want my test case ...
HkFreaKuser1673718's user avatar
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"; ...
Adalarasan_Serangulam's user avatar
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. ...
Svish's user avatar
  • 158k
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 ...
walters's user avatar
  • 1,467
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 ...
user avatar