Questions tagged [junit-runner]

The JUnit runner checks, makes and launches the unit tests.

The default runner implementation guarantees that the instances of the test case class will be constructed immediately before running the test and that the runner will retain no reference to the test case instances, generally making them available for garbage collection

124 questions
1
vote
0 answers

Filter/Ignore JUnit Testmethods listed in File during execution

Given: A package with Testclasses. Each test class has hundreds of test methods. Some of those test classes use their own runner. A file with strings of that form: absolut.path.Testclass.testMethod Should: Run only those test methods that are…
KFleischer
  • 942
  • 2
  • 11
  • 33
1
vote
2 answers

How to correctly shut down a JUnit-Runner?

I made my own JUnit-Runner by implementing org.junit.runner.Runner, so that I can run my UnitTests with them using the @RunWith-Annotation. It lookes somewhat like this: public class MyRunner extends Runner { private Context myContext; …
Bob
  • 5,510
  • 9
  • 48
  • 80
1
vote
2 answers

PowerMockRunner with Concurrent

I have a JUNIT test that runs with PowerMockRunner.class. Now, I am adding a new test, however, I want to run both the test concurrently. I know I could do this using @RunWith(ConcurrentTestRunner.class) or just by creating a concurrent executor…
Meritor
  • 166
  • 11
1
vote
1 answer

JUnit global before/after

I need some way to execute code before/after each test. This code should be the same for all tests and test cases globally. I was hoping I could use RunListener, but it seems that I need to alter all the tests (or their parent class) to specify…
redhead
  • 1,264
  • 1
  • 17
  • 32
1
vote
1 answer

each Junit test works fine but when trying to make Suite - none work

I'm using eclipse and made two test classes using Junit 4 test case. each of the test classes works fine and now I need to make a TestSuite that will run both of the test classes. the name of the 2 test classes are : GuessManager.class &…
Noam
  • 1,640
  • 4
  • 26
  • 55
1
vote
1 answer

How to run JUnit tests from the command line if classes are in packages?

The class ParserTest is in the package myproject.tests and stored in this directory structure: . └── myproject └── tests └── ParserTest.class Set the CLASSPATH for the current shell session (no -cp option, to keep to java call…
1
vote
1 answer

JUnit 4 API Get Handle to a @Test Method

Using JUnit 4 API, is there a way to get a handle to a method in a test class that are annotated with @Test? Here's what I am currently doing: JUnitCore core = new JUnitCore(); Request request = Request.aClass(MyTest.class); Result result =…
Kesh
  • 1,077
  • 2
  • 11
  • 20
1
vote
0 answers

Suppress android test based on device type?

I run an Instrumentation test suite using Gradle 'connectedCheck' which executes tests on all connected devices. Some tests fail only on certain devices and I want a mechanism to suppress/ignore those tests only for that device. Can anyone tell me a…
Karthik Kota
  • 423
  • 1
  • 5
  • 10
1
vote
2 answers

how to generate html report if my Junit is not run by Ant but by JunitCore.run

I worked on a project in which testclasses are run via JunitCore.run(testClasses) not via Ant because I have to run the project even with no ANT framework (so no Testng for the same reason). But I still need to create html and xml reports same as…
user389955
  • 9,605
  • 14
  • 56
  • 98
1
vote
5 answers

How to open navigation drawer menu in Robotium automation script in android

I have a application with navigation drawer i want to open the drawer menu in Robotium automation script.my application minimum Api level is 11 so i am using action bar sherlock for action bar implementation. Please guide me in right way
Rakki s
  • 1,426
  • 1
  • 18
  • 42
1
vote
0 answers

Can I add a junit listener that can be invoked between test classes, rather than between test cases?

I am having a problem where unit tests are modifying the static state of class Foo and not cleaning up after themselves. This means that a unit test may pass when it is run by itself, but fail when some other unit test runs before it, because the…
John Q Citizen
  • 3,138
  • 4
  • 26
  • 31
1
vote
1 answer

How to tell if called from JUnit?

I think that a piece of code under test should not know that it is under test. Therefore, this question represents an anti-pattern, but I have a need to configure a legacy application in a particular way 'if called from a JUnit integration test'. If…
cmdematos
  • 883
  • 4
  • 12
  • 24
1
vote
1 answer

How to write a JUnit runner that runs a @BeforeCategory method before a TestCase in a @Category?

I'm trying to write a specific JUnit Runner, and I did not find good tutorials / examples online. The requirements are the following : I will have some categorized tests (e.g A.java from category catA, B.java from category catA, C.java from…
facewindu
  • 705
  • 3
  • 11
  • 31
1
vote
1 answer

How can I get more logging feedback when I have a test suite that uses @RunWith?

I have a custom test runner I've made to run a portion of my tests so I can distribute the tests on different jenkins nodes. If all my integration tests were run it would take an hour. So I have 3 servers running 1/3rd of the tests and this only…
Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356
1
vote
1 answer

Using JUnit 4 with HierarchicalContextRunner and JUnitParamsRunner

I want to create the following test class with JUnit4: import junitparams.JUnitParamsRunner; import org.junit.runner.RunWith; import…
Juergen
  • 3,489
  • 6
  • 35
  • 59
1 2 3
8 9