junit3

JUnit3 and Junit4 XML Reports with Maven

喜你入骨 提交于 2019-12-19 06:05:15
问题 I am trying to figure out how to use the supposed reporting capabilities of JUnit (3 and 4) in conjunction with Maven, but Google searches aren't turning up much in the way of how to actually run JUnit (via Maven), get a report for each test (or all tests) and what format it will be in. So, my multi-part questions is: 1.) What sort of XML format is JUnit (3/4) capable of outputting? 2.) What sort of calling convention/arguments are required for JUnit to output these reports? 3.) Where are the

JUnit Exception Testing

会有一股神秘感。 提交于 2019-12-17 23:18:43
问题 Edit: Not JUnit 4 available at this time. Hi there, I have a question about "smart" exception testing with JUnit. At this time, I do it like this: public void testGet() { SoundFileManager sfm = new SoundFileManager(); // Test adding a sound file and then getting it by id and name. try { SoundFile addedFile = sfm.addSoundfile("E:\\Eclipse_Prj\\pSound\\data\\Adrenaline01.wav"); SoundFile sf = sfm.getSoundfile(addedFile.getID()); assertTrue(sf!=null); System.out.println(sf.toString()); sf = sfm

Maven 2 Not Running Junit 4 Tests

拟墨画扇 提交于 2019-12-12 10:38:24
问题 I'm having an issue getting surefire to run Junit4 tests. This same issue was reported in https://stackoverflow.com/questions/2021771?sort=newest#sort-top but the solution there was to removed the offending dependency whose transitive dependency caused the inclusion of junit3. In my case the dependency is necessary. I'm trying to figure out how to exclude transitive dependencies to junit3 so it is not included in the surefire:test classpath. Below are my pom.xml and the output from "mvn -X

Android - testing if another activity has started

梦想的初衷 提交于 2019-12-10 18:49:02
问题 I am trying to test the following scenario, enter a letter in the autocomplete textview, scroll down and select one of the options, then click a button, The button click starts a new activity. I want to check if the new activity has begun or not. This is the test method. public void testSpinnerUI() { mActivity.runOnUiThread(new Runnable() { public void run() { mFromLocation.requestFocusFromTouch(); // use reqestFocusFromTouch() and not requestFocus() } }); //set a busstop that has W in it,

how to accept input from user in Junit console

南楼画角 提交于 2019-12-07 05:06:19
问题 I am trying to write Junit test case for the function given below: class A{ int i; void set() { Scanner in=new Scanner(System.in); i=in.nextInt(); } } Now my problem is when i create a Junit test case for it, it does not except input from user: public void testSet() throws FileNotFoundException { System.out.println("set"); A instance = new A(); int i=1; instance.set(i); // TODO review the generated test code and remove the default call to fail. //fail("The test case is a prototype."); }

Error when defining inner classes in a Test class in JUnit

霸气de小男生 提交于 2019-12-05 17:48:30
问题 I'm having some problems when defining inner classes in a Test class inherited from TestCase, for JUnit 3. Scenario is like following: Foo.java public class Foo { public void method() { ... } } FooTest.java public class FooTest extends TestCase { public class Bar extends Foo { public void method() { ... } } public void testMethod() { ... } } Now, if I run this from Eclipse, the tests run ok, but if I try to run from an Ant task it fails: [junit] junit.framework.AssertionFailedError: Class Foo

how to accept input from user in Junit console

冷暖自知 提交于 2019-12-05 09:01:11
I am trying to write Junit test case for the function given below: class A{ int i; void set() { Scanner in=new Scanner(System.in); i=in.nextInt(); } } Now my problem is when i create a Junit test case for it, it does not except input from user: public void testSet() throws FileNotFoundException { System.out.println("set"); A instance = new A(); int i=1; instance.set(i); // TODO review the generated test code and remove the default call to fail. //fail("The test case is a prototype."); } Please suggets what should i do to accept input from user. You can use System.setIn() to mock user input:

Error when defining inner classes in a Test class in JUnit

◇◆丶佛笑我妖孽 提交于 2019-12-04 02:45:59
I'm having some problems when defining inner classes in a Test class inherited from TestCase, for JUnit 3. Scenario is like following: Foo.java public class Foo { public void method() { ... } } FooTest.java public class FooTest extends TestCase { public class Bar extends Foo { public void method() { ... } } public void testMethod() { ... } } Now, if I run this from Eclipse, the tests run ok, but if I try to run from an Ant task it fails: [junit] junit.framework.AssertionFailedError: Class Foo$Bar has no public constructor TestCase(String name) or TestCase() Bar is NOT a Test class, it's just a

How to run Junit TestSuites from gradle?

南笙酒味 提交于 2019-12-03 10:36:18
I am trying to migrate from Ant build to Gradle in my project. There are a bunch of test cases (subclasses of junit.framework.TestCase) and few test suites (subclasses of junit.framework.TestSuite). Gradle automatically picked up all test cases(subclasses of junit.framework.TestCase) to be run, but not the suites (subclasses of junit.framework.TestSuite). I probably could work around by calling ant.junit to run it. But, I feel there should be a native easy way to force gradle to pick them and run. I couldn't find anything in the document . Am I missing something? This was hard for me to figure

JUnit3 and Junit4 XML Reports with Maven

走远了吗. 提交于 2019-12-01 03:51:34
I am trying to figure out how to use the supposed reporting capabilities of JUnit (3 and 4) in conjunction with Maven, but Google searches aren't turning up much in the way of how to actually run JUnit (via Maven), get a report for each test (or all tests) and what format it will be in. So, my multi-part questions is: 1.) What sort of XML format is JUnit (3/4) capable of outputting? 2.) What sort of calling convention/arguments are required for JUnit to output these reports? 3.) Where are the reports output? 4.) Can these reports be generated while running via Maven or is my only option to use