RANDOMIZED TESTING ================== JUnit test runner and plugins for running JUnit tests with pseudo-randomness. See the following for more information: Docs: https://github.com/randomizedtesting/randomizedtesting/wiki Bugs: https://github.com/randomizedtesting/randomizedtesting/issues CI: http://builds.carrot2.org/browse/RNDTEST See LICENSE.txt to make your company's lawyer happy. See CHANGES.txt for API changes and updates.
Randomized Testing (Core JUnit Runner, ANT, Maven)
Overview
Comments
-
Question: Enhance ThreadLeakControl to print additional metadata
In Solr we have MDCAwareThreadPool that tracks a submitterStackTrace for the threads that it manages. This information would be really useful to print on leaked threads when it is available, since it would help pinpoint where this thread came from that was leaked (useful when it looks like a generic http client thread, for example).
I don't think it makes sense for the runner to know about Solr's convention, but maybe we can make some kind of extensible API cut point that would allow us to customize how we gather stack trace information?
-
Convenience System property setting on SystemPropertiesRestoreRule?
SystemPropertiesRestoreRule is pretty nice. It'd be even nicer if I could conveniently set particular system properties at the site of the rule definition, to make it clear why the rule is there in the first place. This would work by adding a convenient
(String key, String value)
constructor, and another(Map<String, String> properties)
when there is more than one. My proposal here is inspired by https://gist.github.com/mike10004/7f6865b46c23005e9496a53589194788 which I found with some googling.Of course this isn't necessary. I can define this rule, and then somewhere in some
@Before
or wherever, I can callSystem.setProperty(name, value
. But my proposal keeps these linked together. One might want to define System.setProperty as a "forbidden API", in tests, and instead rely purely on your JUnit Rule to manipulate them, which communicates to readers that it's important to clean up after test execution. -
Provide means to use RandomizedTesting without the test runner.
I work on a project that depends on lucene-test-framework for its wonderful test utilities to validate use of text analysis components. The project does not use randomizedtesting's test runners. I want to use some test utilities that I cannot invoke now because they directly/indirectly invoke randomizedtesting which fails because there is no context:
java.lang.IllegalStateException: No context information for thread: Thread[id=1, name=main, state=RUNNABLE, group=main]. Is this thread running under a class com.carrotsearch.randomizedtesting.RandomizedRunner runner context? Add @RunWith(class com.carrotsearch.randomizedtesting.RandomizedRunner.class) to your test class. Make sure your code accesses random contexts within @BeforeClass and @AfterClass boundary (for example, static test class initializers are not permitted to access random contexts).
Asking users/projects to a specific test runner can be an awkward constraint. For some of my tests, I can use your runner, for some, I cannot because another is used.
When I look at RandomizedContext, there isn't sufficient access for me to manually manage it's lifecycle outside of your runner. I would like this added and/or a JUnit Rule as an option. Such a Rule wouldn't bring all the baggage that RandomizedRunner has -- no thread leak detection. Just provide what this project's namesake is -- randomness. That's all.
-
Move lucene's mockfs into junit or randomizedtesting?
Lucene mockfs (https://github.com/apache/lucene-solr/tree/master/lucene/test-framework/src/java/org/apache/lucene/mockfile) basically tries to wrap the default
nio.2
filesystem with a provider that changes things up:- ShuffleFS: Directory listings in an unpredictable but deterministic order regardless of underlying filesystem order (e.g. OS X returns in sorted order, Linux does not)
- LeakFS: Fails tests if they leave open filehandles. (Only files with
nio.2
api, not sockets, but useful). - DisableFsyncFS: Makes actual fsync() calls a no-op. If you are e.g. a database or similar and using the filesystem seriously, this speeds up tests with no downside...
- VerboseFS: Prints destructive filesystem operations to infostream (Logging writes/deletes/renames/etc). For debugging.
- ExtrasFS: Adds 'bonus' files to directories. Kind of annoying and lucene-specific. But you could tame it by only adding 'realistic bonus files' like '.DS_Store'.
- WindowsFS: Acts like windows (imperfect, just prevents deleting open files at the moment)
The idea of the thing is that you can build a chain, of several of these, wrapping the default filesystem. None of the stuff is really dependent on lucene though, and some of these filesystem issues are real traps (e.g. system-specific stuff like order of results from listing directories)?
However, there are some problems/downsides/questions as it stands out:
- We wrap at test runner level (we pass to getTempDir() and all lucene tests use that). Ideally it would be at a higher level and pass system properties to the jvm to wrap the default filesystem so that it can't be backdoored by calls to e.g.
FileSystem.getDefault()/Paths.get()/...
. I have hacked it to work this way for debugging production code (VerboseFS) with https://github.com/rmuir/verbosefs . - NIO.2 api is incompletely wrapped for some stuff. We don't yet wrap the FileLock API (because lucene has a bad history with fs locking code, but we should do it now), some implementations are incomplete because Lucene only uses a subset of the filesystem operations.
- There are unit tests, but they could be improved...
- There are some dragons in the current code, while it works for lucene's case, if you add to an app more extensively using the java NIO apis, you will find: https://github.com/rmuir/verbosefs/blob/master/src/rmuir/FilterPath.java#L57 These are basically VFS layer violation bugs with things being wrapped twice or something like that.
- Is NIO.2 really being adopted? Not many projects are using it yet. But if you fully cut over, you can take advantage of stuff like this.
Anyway, I'd be interested in helping out if its a better home or fixes to the issues or whatever. Or may be we could only take some of ideas and try to rewrite it to work better, etc.
-
Implement true heartbeat from the forked JVM
A "true" heartbeat would provide several answers to problems we're currently facing:
- it's not known where the "deadlocked" JVM actually is (stack traces),
- it's not known whether it's a resource (no cpu usage) or active (spinloop) deadlock, sending back the stack traces a few time could answer this (as well as maybe generic CPU load),
- it's not known whether the forked process is still alive at all (should heartbeat messages stop arriving, we can try to terminate the forked process and end with a build error).
Releases(release/2.8.0)
-
release/2.8.0(Jun 28, 2022)
This release includes two minor changes and should be fully backwards-compatible, unless deep internals of the code were used (such as event subscribers).
-
GH-303: Messages from ThreadLeakControl.checkThreadLeaks can be inconsistent due to mismatched use of thread data.
-
GH-304: Replace master/slave with main/forkedjvm terminology. This change may result in backward incompatibilities if you used low-level event bus subscription methods or JSON reports. Grep and replace 'slave' with 'forkedJvm' and 'master' with 'main' seed.
Source code(zip)
-
-
release/2.7.9(Oct 22, 2021)
Other:
-
Update ASM to 9.2 to support JDK 17
-
Update JUnit dependency to 4.13.1.
-
Update Ant dependency to 1.9.15.
Source code(zip)
-
-
release/2.7.8(Jul 7, 2020)
Improvements
-
GH-289: Bump asm to 8.0.1.
-
PR-287: Bump dom4j from 2.1.1 to 2.1.3.
Source code(zip)
-
-
release/2.7.7(Mar 2, 2020)
Bug Fixes
- GH-283: RandomizedRunner throws
NoTestsRemainException
from the constructor when method filter is supplied and no methods match (Mark Vieira).
Source code(zip)
- GH-283: RandomizedRunner throws
-
release/2.7.5(Mar 2, 2020)
Improvements
-
Switch to simple-xml-safe.
-
throw NoTestsRemainException if Filterable.filter removes all tests.
Source code(zip)
-
-
release/2.7.6(Mar 2, 2020)
Improvements
- Use thread join internally to wait for forked timeouting test thread instead of a hardcoded sleep (dumb!).
Source code(zip)
-
release/2.7.4(Oct 23, 2019)
Bug Fixes
- GH-280: Potential race condition in global temp folder generation.
Source code(zip)
-
release/2.7.3(May 7, 2019)
Bug Fixes
- GH-276: Annotations on overriden methods are not picked up (annotations on overrides of @Test methods are not picked up).
Source code(zip)
-
release/2.7.2(Dec 14, 2018)
Bug Fixes
- GH-275: Timeouts can deadlock on trying to interrupt leaked threads.
Improvements
- GH-274: PrintEventListener should emit display name if method name is not available in testIgnored callback.
Source code(zip)
-
release/2.7.1(Nov 20, 2018)
Bug fixes
- GH-271: Methods with ( or ) in them can't be selected directly using glob filters.
Source code(zip)
-
release/2.7.0(Sep 10, 2018)
Bug Fixes
- GH-269: 2.6.x runners and junit 4.12 show much noise for a single test method in IntellJ Idea (thanks Vladimir Dolzhenko).
Changes in Backwards Compatibility
- GH-270: Upgrade to support JUnit 4.12. This also means that Hamcrest is required (as JUnit 4.12 uses it).
Source code(zip)
-
release/2.6.4(Sep 5, 2018)
Bug Fixes
-
GH-247: Allow java.io.tmpdir to be placed under cwd with isolated directories and nonEmptyWorkDirAction=wipe.
-
GH-255: Invalid event nesting on security logging crashes the runner.
-
GH-266: QUIT event may not be read from the event log on slow machines.
-
GH-267: Project does not build/ test on Java 11.
Improvements
-
An additional property 'junit4.tempDir' is passed to forked JVMs to allow easier configuration of security policy files. This folder must have read/ write file policy.
-
Added a test case that runs with a security manager enabled.
-
GH-253: IntelliJ only recognizes proper test methods for re-runs when descriptions have " [...]" instead of " {...}. This fix uses square brackets on IntelliJ runner.
Changes in Backwards Compatibility
- GH-265: Deprecate RandomizedTest.randomInt(v) and RandomizedTest.randomLong(v).
Source code(zip)
-
-
release/2.6.3(Jun 14, 2018)
A fixup of bytecode incompatibility resulting from covariant API changes in Java (2.6.2 cross-compiled from Java 9 to Java 8).
Source code(tar.gz)
Source code(zip)
-
release/2.6.2(Jun 11, 2018)
New Features
- GH-261: Ant and Maven runner can specify external JUnit 4 RunListeners. (Steven Zaluk)
Source code(zip)
-
release/2.6.1(Jun 11, 2018)
Bug Fixes
- GH-260: maven plugin should use dom4j 2.0.2 (avoids illegal access warnings under Java 9 and later).
Source code(zip)
-
release/2.6.0(Jun 11, 2018)
Changes in Backwards Compatibility
-
GH-259: Java 1.8 is now the minimum supported JRE.
-
GH-258: add support for parsing class files compiled into Java 9 or Java 10 bytecode.
Source code(zip)
-
-
release/2.5.3(Aug 31, 2017)
Bug fixes
- GH-251: Fixes test case filtering in IDEs (IntelliJ, Eclipse). The tests are now filtered out eagerly from the returned suite's
Description
and don't show in the user interface at all. This also applies to-Dtests.method=...
patterns.
Source code(zip)
- GH-251: Fixes test case filtering in IDEs (IntelliJ, Eclipse). The tests are now filtered out eagerly from the returned suite's
-
release/2.5.2(Jul 4, 2017)
Bug fixes
- GH-250: Non-bootstrapped ForkedJvmInfo causes NullPointerExceptions (can happen on slow machines with low heartbeat setting).
Source code(zip)
-
release/2.5.1(Apr 13, 2017)
Changes in Backwards Compatibility
- GH-248: Cleaning up some confusion on
RandomizedTest.randomAscii*
andRandomStrings.randomAscii*
methods. These methods generated random strings based on letters from the Unicode basic latin block (C0). All these methods are now deprecated and will be removed in favor of more explicit methods that tell exactly (?) what kind of letters are involved (Ryan Ernst, Dawid Weiss). For details, see:
Source code(tar.gz)RandomStrings.randomAsciiLettersOfLength(..) RandomStrings.randomAsciiLettersOfLengthBetween(..) RandomStrings.randomAsciiAlphanumOfLength(..) RandomStrings.randomAsciiAlphanumOfLengthBetween(..)
Source code(zip)
- GH-248: Cleaning up some confusion on
-
release/2.5.0(Jan 23, 2017)
Changes in Backwards Compatibility
- GH-243: Switches from File to NIO (Path) APIs in a few places may result in slightly different runner's behavior (on exceptional conditions).
- GH-244: the new onNonEmptyWorkDirectory attribute's default value is 'fail' which may break existing builds that have garbage in work directories of forked JVMs. Change explicitly to any of the alternatives ('ignore' or 'wipe') or fix your build to wipe the temporary folders yourself.
- GH-246: RequireAssertionsRule enforcement optional (consistent with "-Dtests.asserts"); explicit target class is also required. (Dawid Weiss)
New Features
- GH-244: A new attribute "onNonEmptyWorkDirectory" controls the action to take on non-empty initial work directory (for isolated JVMs). (Dawid Weiss)
Other Changes
- GH-246: RequireAssertionsRule enforcement optional (consistent with "-Dtests.asserts"); explicit target class is also required. (Dawid Weiss)
- GH-243: Switches from File to NIO (Path) APIs in a few places in the ANT runner. Improved messages concerning non-empty temporary JVM folder (both initially and at the end of the tests' run). (Dawid Weiss)
- GH-245: Integrate Forbidden-APIs check and fix follow-up issues. (Dawid Weiss)
Source code(zip)
-
release/2.4.1(Jan 18, 2017)
New Features
- GH-240: Add RandomPicks.randomFrom on primitive arrays. (Dawid Weiss)
Bug Fixes
- GH-242: RandomizedTest.nextTempName uses locale-sensitive String.format. (Dawid Weiss)
Source code(zip)
-
release/2.4.0(Oct 20, 2016)
Changes in Backwards Compatibility
-
GH-237: Methods previously found in RandomInts have been moved to RandomNumbers. (Dawid Weiss)
-
GH-234: Run strict validation (thread-ownership, lifecycle) in AssertingRandom only with assertions enabled. This change means that running without -ea will from now on ignore the fact that random context's Random instance is shared where it shouldn't be. On the other hand, any additional memory barriers can be now avoided, in particular when used in conjunction with @TestContextRandomSupplier (see GH-235 below).
To enable consistent checking, enable assertions selectively (for com.carrotsearch.randomizedtesting package only). (Dawid Weiss)
-
GH-229: The default implementation of the Random instance returned from the randomization context has been changed to Xoroshiro128P, details here: http://xoroshiro.di.unimi.it/
The returned Random isn't synchronized and should yield much better pseudo-random sequences than the default Java's Random. (Dawid Weiss)
New Features
- GH-238: Add BiasedNumbers (random selection with bias towards "evil" numbers, in particular floats) as an alternative to RandomNumbers. (Dawid Weiss)
- GH-237: Rename RandomInts to RandomNumbers and add methods operating on longs. (Dawid Weiss).
- GH-235: A new class annotation was added: @TestContextRandomSupplier allows declaring a custom class (RandomSupplier) that supplies a Random for the given seed. This supplier can return any Random instance for the given initial seed (secure random, faster-than-jdk random, non-random random...). (Dawid Weiss)
Bug Fixes
- GH-233: some adjustments and refactorings in an attempt to avoid deadlocks on suite timeouts. Very hard to reproduce (i.e., impossible) and some very odd stack traces too. (Dawid Weiss)
Other Changes
- GH-232: Rework reporting of ignored, assumption-ignored, filtering-expression ignored tests. (Dawid Weiss)
- GH-218: There are some internal changes in handling @Nightly annotation. The support for @Nightly is now provided via GroupEvaluator (and this class is now public, with methods allowing inspection of whether a test would be filtered out or not). (Dawid Weiss)
Source code(zip)
-
-
release/2.3.4(Apr 4, 2016)
Bug Fixes
- GH-227: Static leak detector should print the "original" field in the test class that lead to ram usage tester failure (PR #227, Uwe Schindler)
Source code(zip)
-
release/2.3.3(Jan 14, 2016)
Bug Fixes
- GH-225: Maven mojo's additionalClasspathElements option only adds empty strings to classpath. (@Anaros via Dawid Weiss).
Source code(zip)
-
release/2.3.2(Dec 7, 2015)
Changes in Backwards Compatibility
- GH-222: Make unexpected JVM output available to listeners. This issue makes JVM output available to ANT JUnit4's listeners so that they can log it properly. Previously the JVM output was copied to System.out which could be hard to work with. See TextReport.onJvmOutput for an example. The default value of 'jvmOutputAction' has been changed from 'pipe, warn' to 'listeners, warn' so that listeners get notified about JVM output instead of it being copied directly to sysout. (Dawid Weiss, Ryan Ernst).
Other Changes
- GH-220: Add an indication of the number of failed suites so far to text report. (Dawid Weiss, Chris Hostetter).
- GH-224: Remove excess use of Guava's collections. (Dawid Weiss)
- GH-221: Upgrade to Guava 19.0-rc3. (Dawid Weiss, Ryan Ernst)
Bug Fixes
- PR #223: Access private fields within doPrivileged (Robert Muir)
Source code(zip)
-
release/2.3.1(Nov 9, 2015)
New Features
- GH-219: Add randomBytes generator utility. (Dawid Weiss)
- GH-190: RandomizedContext should provide the current test case method (via RandomizedContext.current().getTargetMethod()). (Dawid Weiss)
- GH-217: Permit running tests on the same instance of the suite class via TestCaseInstanceProvider annotation. See Test018TestCaseInstanceProviders example. (Dawid Weiss).
Source code(zip)
-
release/2.3.0(Nov 6, 2015)
New Features
- GH-216: Custom test case argument formatters in parameter factories. See ParametersFactory.argumentFormatting and Test007ParameterizedTests example. (Dawid Weiss).
- GH-194: Flexible test case ordering via the new annotation: TestCaseOrdering. (Dawid Weiss)
Bug Fixes
- GH-215: In certain cases test case names could be duplicated (be identical), which could confuse IDEs. (Dawid Weiss)
Source code(zip)
-
release/2.2.0(Oct 28, 2015)
Changes in Backwards Compatibility
- PR #178: Move to Java 1.7 and use the java NIO 2 API for temp files. (Simon Willnauer)
- GH-184: RandomizedTest should not extend Assert. This permits easier use of other frameworks (like assertj) via static imports without naming conflicts. (Olivier Bourgain, Dawid Weiss)
New Features
- GH-191: "Tests with failures" should repeat the master seed at the end of the report. (Dawid Weiss)
Bug Fixes
- GH-192: Reworked json streaming to get rid of gson and permit dumping JVM-related diagnostics (security manager policy dumps, etc.). (Dawid Weiss)
- GH-206: Potential NPE in checking getDefaultUncaughtExceptionHandler. (Dawid Weiss)
Other Changes
- GH-210: Make RR compilable/ testable under Java 1.9. (Dawid Weiss)
- GH-209: Remove dependency on commons-io. (Dawid Weiss)
- GH-204: modernize and clean up project layout. (Dawid Weiss)
Source code(zip)
-
release/2.1.17(Sep 22, 2015)
Bug Fixes
- GH-201: Tests still running (and zombified) after suite timeout occurred. (Dawid Weiss)
Other Changes
- GH-205: Report test seed in halt on failure message. (Dawid Weiss)
- GH-203: report the number of completely ignored suites in the summary. (Dawid Weiss)
- PR #202: support running with security manager and limit the required permissions. (Robert Muir)
Source code(zip)
Automation Testing | RESTful webservices | Java | RestAssured | OAuth 2.0 | Lombok | TestNG | Maven | ExtentReport | Allure Reports | Java mail API | Design Patterns (Singleton) | Jenkins | Data-Driven Testing using JSON file | Expected Data using XML file
MasterRestAssuredFramework With further updates - This project is designed and developed with the help of - Udemy course (OmPrakash Chavan - REST Assu
A simple yet powerful parameterized test runner for Java.
TestParameterInjector Introduction TestParameterInjector is a JUnit4 test runner that runs its test methods for different combinations of field/parame
A BDD-style test runner for Java 8. Inspired by Jasmine, RSpec, and Cucumber.
Spectrum A colorful BDD-style test runner for Java Spectrum is inspired by the behavior-driven testing frameworks Jasmine and RSpec, bringing their ex
Java testing framework for testing pojo methods
Java testing framework for testing pojo methods. It tests equals, hashCode, toString, getters, setters, constructors and whatever you report in issues ;)
Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
Testcontainers Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium we
CodeSheriff is a simple library that helps you in writing JUnit tests that check the quality of your code
CodeSheriff is a simple library that helps you in writing JUnit tests that check the quality of your code. For example, CodeSheriff may fail because you have methods in your code that have more than X lines of code, or that have complexity greater than Y.
JUnit 5 Parameterized Test Yaml Test Data Source
Yamaledt — JUnit 5 Parameterized Tests Using Yaml and Jamal Introduction and usage Note This is the latest development documentation. This is a SNAPSH
Exercicio envolvendo criação de Classe, Junit 5 e exception
ClasseData Complemente a classe Data desenvolvida anteriormente para que lance uma ExcecaoDataInvalida. Com esta única exceção, você deverá ser capaz
Exercico com Junit 5, UML, Interação de classes e Exception
AcessoClube Exercico com Junit 5, UML, Interação de classes e Exception Exercicio: Projete e desenvolva um sistema de controle de acesso a um clube co
This is a repository to collect JUnit Tests for GAD exercises at TUM in SS21
TUM_GAD_Tests_SS21 This is a repository to collect JUnit Tests for GAD exercises at TUM in SS21. These tests have been written by students for student
A template for Spring Boot REST API tested with JUnit 5 and Cucumber 6
demo-bdd Un template Spring Boot pour lancer un BDD/ATDD avec Cucumber 6 et JUnit 5. Maven et le JDK 17 seront nécessaires. Exécuter les tests Le proj
IntelliJ IDEA and JUnit: Writing, Finding, and Running Tests
IntelliJ IDEA and JUnit: Writing, Finding, and Running Tests ?? Webinar https://blog.jetbrains.com/idea/2021/11/live-stream-recording-intellij-idea-an
Testes unitários em Java utilizando JUnit 5
Testes unitários em Java utilizando JUnit Este curso tem como objetivo habilitar o(a) aluno(a) a testar soluções desenvolvidas na linguagem Java, torn
Testes unitários em Java utilizando JUnit
Testes unitários em Java utilizando JUnit Este curso tem como objetivo habilitar o(a) aluno(a) a testar soluções desenvolvidas na linguagem Java, torn
JUnit 5 extension for easy-random
Easy Random/Faker JUnit 5 extension The simple, stupid random Java™ beans generator for JUnit 5 The easy random extension provides a test with randoml
Intercept network request by running Selenium tests with JUnit on LambdaTest cloud.
Run Selenium 4 Tests With JUnit On LambdaTest Blog ⋅ Docs ⋅ Learning Hub ⋅ Newsletter ⋅ Certifications ⋅ YouTube Learn how to use JUnit framewor
Override device mode by running Selenium test with JUnit on LambdaTest cloud.
Run Selenium 4 Tests With JUnit On LambdaTest Blog ⋅ Docs ⋅ Learning Hub ⋅ Newsletter ⋅ Certifications ⋅ YouTube Learn how to use JUnit framewor
Emulate geolocation by running Selenium tests with JUnit on LambdaTest cloud.
Run Selenium 4 Tests With JUnit On LambdaTest Blog ⋅ Docs ⋅ Learning Hub ⋅ Newsletter ⋅ Certifications ⋅ YouTube Learn how to use JUnit framewor
Testes unitários em Java utilizando JUnit
Testes unitários em Java utilizando JUnit Este curso tem como objetivo habilitar o(a) aluno(a) a testar soluções desenvolvidas na linguagem Java, torn