by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 26 22:35
    swankjesse commented #1041
  • May 26 15:23
    svenruppert commented #2011
  • May 26 13:30
    Vampire closed #2306
  • May 26 13:30
    Vampire commented #2306
  • May 26 13:08
    sbrannen commented #2306
  • May 26 13:07
    sbrannen commented #2306
  • May 26 10:24
    Vampire opened #2306
  • May 25 06:13
    kriegfrj opened #2305
  • May 24 12:30
    chenrui333 commented #128
  • May 24 08:44
    marcphilipp closed #128
  • May 24 08:44
    marcphilipp commented #128
  • May 24 08:42

    marcphilipp on master

    Run workflow for PRs as well (compare)

  • May 24 08:34
    marcphilipp commented #127
  • May 24 08:34

    marcphilipp on master

    Upgrade Bazel version to 3.1.0 … (compare)

  • May 24 08:34
    marcphilipp closed #127
  • May 24 08:34
    marcphilipp edited #127
  • May 23 19:36
    chenrui333 synchronize #128
  • May 23 19:33
    chenrui333 commented #127
  • May 23 19:32
    chenrui333 opened #128
  • May 23 19:28
    chenrui333 commented #127
Matthias Bünger
@Bukama
Does @Execution annotation should be present on the "singular" annotation or on the "plural" one when the annotation is repeatable? With "plural" I mean the annotation which only holds an array of the "singular" ones
Alvaro Esteban Pedraza
@aepedraza
Hello everyone, I'm new as a contributor and I want to start coding for the project. I'd like to know if there is a guide or walkthrough to setup the project in Eclipse
Alvaro Esteban Pedraza
@aepedraza
@sormuras are you the moderator here?
Matthias Bünger
@Bukama
He is one of the core maintainers of JUnit
Alvaro Esteban Pedraza
@aepedraza
thanks @Bukama . Do you know if there's a wiki about how to setup the project in Eclipse?
Christian Stein
@sormuras
Heja, @aepedraza - no, there's none. Most of the JUnit team members use IDEA, you simply let the default Gradle Plugin of IDEA do its thing.
@sbrannen knows the secrets how setup JUnit 5 for Eclipse. IIRC, you may use the provided Gradle Wrapper to create Eclipse configuration files.
Via gradlew eclipse perhaps?
Here's a blog that covers that topic in a more general manner: https://www.vogella.com/tutorials/EclipseGradle/article.html
Alvaro Esteban Pedraza
@aepedraza
ok, I think I'll switch to IDEA. I though you were using Eclipse because of the formatter and .importorder file in the repository. Thank you very much @sormuras
Christian Stein
@sormuras
You're welcome.
Brandt B.
@babeal
Is there a way to package a JUnit/Maven integration test project into assemblies, so that it can be deployed executed and produce surefire reports without having to distribute the source project?
Linus Kullman
@oi19lkn_gitlab
Hi! I'm supposed to write tests for my classes using Junit5 but I don't know what it is and how you're supposed to do it.
Mikael Elm
@mickeelm
@oi19lkn_gitlab if you're not familiar with the concept of unit testing in general, I'd start looking into that just to get a grip on why you should be writing tests. After that, there's the official documentation of course but maybe just google junit5 tutorial and use a hands-on-guide, take it from there.
MrLukas007
@MrLukas007

Hi all! I want to use junit5 for my frontend tests. And I want to use annotation "test" as a test case. So my real test will be in one class (file), and contains test cases (really it will be "test" from junit). And I have two problems.

  1. Since my test cases depend on each other, I want to stop my test scenario if one case (really it will be "test" from unit) is failed.
  2. I want to take a screenshot if my test is failed.
    So I need to know if my current test case (really it will be "test" from unit) is failed, e.g. I can check it in before each annotation. But when I try to get test status - I receive a strange results. I check results in parent class - CommonTest, all other test classes inherited from him. And I always see the same incorrect failures count, even I have no failed tests.
    Result result = JUnitCore.runClasses(AbstractTest.class); // 1
    Result result = JUnitCore.runClasses(getClass()); // 3
    logger.info(result.getFailureCount());
    Also I tried to use Rule annotation.
    I created a separate class
public class ScreenshotOnFailure extends TestWatcher {

@Override
    protected void failed(Throwable t, Description description) {
        System.out.println("failed"); 
}
}

And add rule annotation to my base test class or event to child test class

    @Rule
 public ScreenshotOnFailure failure = new ScreenshotOnFailure();

But I don`t see my on failed message on test fail.
Could someone please help me, and tell me what's wrong or some better correct implementations for my test framework.
Thanks!

Greg Chabala
@chabala
Hello all. I'm trying to migrate my tests to junit5 without relying on the junit-vintage-engine, but I can't find a good replacement for Assume.assumeThat(T actual, Matcher<T> matcher). It looks like there was a push to separate junit from Hamcrest, so all the matcher based methods moved to that project, but not the assumeThat variants. I've tried making do with the boolean checks provided in Assumptions, a la Assumptions.assumeTrue(is(equalTo("that").matches("this"));Unfortunately that's cumbersome, loses the fluent grammar, and also loses the detail of how the assumption failed.
Is there a recommended way to do this with junit5, or is this a missing feature? I'm guessing it would need to be added to Hamcrest.
Lee Turner
@leeturner
We we migrated to junit 5 and decided to go completely with the assertj library instead of the junit assert methods. The fluent grammar is nice and easier to read.
Greg Chabala
@chabala
Well, AssertJ does have assumptions. I've not looked at it before, but this code is pretty wild. Instead of just generic matchers, there's a concrete Assertion class for every type they support. The main entrypoint with the 'assertThat' overloads is 3k lines. Which explains why their jar is 4.5MB, compared to Hamcrest's 120 KB.
Matthias Bünger
@Bukama
Can also suggest to use AssertJ
AssertJ is used By JUnit Jupiter and the pioneer extension pack too
Lee Turner
@leeturner
If you don’t like AsertJ there are other fluent libraries like Google Truth - https://truth.dev/
Alvaro Esteban Pedraza
@aepedraza
Hi, I was checking the code and the up-for-grabs issues but seems overwhelming for a newbie in this codebase, is there some kind of intro training or documentation I can follow before diving in the issues?
MrLukas007
@MrLukas007

Hello, is it possible to make an order without annotation order?

    @Test
    @Order(1)    
    public void firstTest() {
    }

    @Test
    @Order(2)    
    public void secondTest() {
    }

    @Test
    @Order(3)    
    public void thirdTest() {
    }

I just want the tests to go one by one the way they are located in the class
Is it possible?

Christian Stein
@sormuras
No, not possible. The ordering of methods at runtime is not guaranteed to be in same order at source level.
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Class.html#getDeclaredMethods()
The elements in the returned array are not sorted and are not in any particular order.
Line numbers persisted into .class files are okay-ish approximation, but comes a agent or another instrumention tool ... those numbers aren't reliable anymore.
See also: junit-team/junit5#1919
MrLukas007
@MrLukas007
ok... will wait #1919
thanks
Christian Stein
@sormuras
@MrLukas007 did you scan https://github.com/junit-team/junit5/wiki/Third-party-Extensions#junit-jupiter-extensions for an existing solution regarding frontend tests?
Marcin L
@the-thing
Hi, Why org.junit.jupiter.api.Assertions#assertThrows(java.lang.Class<T>, org.junit.jupiter.api.function.Executable, java.lang.String) does not validate the message if the expected throwable match? Isn't this flawed? Quite often the same exception type is thrown by a method, but the message is different e.g. validation of two separate method arguments etc. To make sure that you covered all the paths and the paths stay the same after future changes you need to validate the message.
I'm actually asking about this, because ExpectedException got depracted in jUnit4 and suggestion is made to use assertThrows.
It doesn't perform any further checks -- those are up to you to implement by inspecting the return exception instance.
    @Test
    void exceptionTesting() {
        Exception exception = assertThrows(ArithmeticException.class, () ->
            calculator.divide(1, 0));
        assertEquals("/ by zero", exception.getMessage());
    }
Marcin L
@the-thing
thanks, yes I figured out that I can verify by inspecting a return value, still I would expect a method that takes Class<?> and String as an argument to verify both
I can live with it
Christian Stein
@sormuras
I guess, you have to. ;-)
Compare the method signatures of other assertXYZmethods in class Assertions: they all follow a common pattern. The trailing String/Supplier<String> is always an optional custom exception error message provided by the user. Jupiter will augment the generated error message with that provided one ... to better hint at the reason what actually made the assertion fail. Context information, environment vars, you name it.
Marcin L
@the-thing
understood
Christian Stein
@sormuras
Khyme
@Khyme
Hello everyone
I have a weird question and I'm not sure it's a junit problem but here we go. I can't seem to make Mockito annotations work at the same time as testcontainers with junit5
Let me illustrate : I have tests with @ExtendWith(MockitoExtension.class) (which enabled me to remove MockitoAnnotations.initMocks(this); ) that work fine.
Same way, I used @Testcontainers + @Container to replace explicit container creation.
both these upgrades work fine
But when I try to have Mocks and containers with annotations, it's broken : my mocked classes are null.
But when dropping the mockitoextension and using old explicit mock initialization, and keeping the @Container, my classes work fine.
Khyme
@Khyme
let it be noted that i also use @TestInstance(Lifecycle.PER_CLASS)
Christian Stein
@sormuras
Hi @Khyme -- sounds like a usage error. Did you scan the TestContainers issue tracker for problems with Mockito? Otherwise, please provide a minimal verifiable example project. Merci.
Khyme
@Khyme
yeah i didnt find much on such intersections with mockito + testcontainers
Alexandr
@AlexDXS
Hi all,
I'm trying to migrate to junit5 from custom runner (extends BlockJUnit4ClassRunner). I have two filters, first check by description.getAnnotation runWith.class + Issue.class, second check issues by custom annotations. Can i use something like class Filter(method shouldRun) in junit5 without tags?
https://i.stack.imgur.com/rdCik.png
darshasurion
@darshasurion

Execute same testsuite in parallel using Junit5.

In Junit 5, we can achieve parallel execution by specifying in junit-platform.properties file. Also we can run the same testsuite multiple times by using @TestTemplate.

Is there a way to combine both approaches?

I want to execute the same testsuite on multiple browsers parallelly while passing browser in @TestTemplate parameter.

So I am looking for, When the testsuite execution starts, the first test should be picked and run on all the available browsers parallelly. and then pick the next.

donahchoo
@donahchoo

Is there a recommended pattern for how to extend tests in Junit5?

I'm dealing with legacy code right now and there is a parent test class and subclasses. The parent test class has @Test annotations the subclasses do not. The subclass constructor sets up some properties via a Supplier and the parent class tests are run using those properties.

Using @Disabled on the parents or making them abstract makes the not run which is good. The abstract solution seems best because it doesn't leave "skipped" messages.

In Junit4 these changes weren't required so I'm wondering if there is some new patter we should be using.