Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Incorrect Testing Failures Message

Aperta
#6 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
java
Ambito
testing

Direzione di ricerca

Riproduci l’esempio ADD utilizzando i casi di test Java mostrati e confronta i messaggi di errore attuali con quelli corretti. Traccia il punto di ingresso del test o della generazione del report responsabile della formattazione degli errori di asserzione; il lavoro è completato quando i test falliti etichettano il valore previsto come expected e il valore restituito come actual.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I've observed that the test reports for some bugs seem to get the “expected“ value and “but was” value obtained reversed.
For example:

Bug_ID: ADD

Buggy_Code:

/* Add two numbers x and y
>>> add(2, 3)
5
>>> add(5, 7)
12 */

public class ADD {
    public static int add(int x, int y) {
        return x | y;
    }
}

Test Cases:

public class TEST_ADD {
    @org.junit.Test(timeout = 3000)
    public void test_0() throws java.lang.Exception {
        int result = humaneval.buggy.ADD.add(0, 1);
        org.junit.Assert.assertEquals(
            result, 1
        );
    }

    @org.junit.Test(timeout = 3000)
    public void test_1() throws java.lang.Exception {
        int result = humaneval.buggy.ADD.add(1, 0);
        org.junit.Assert.assertEquals(
            result, 1
        );
    }

    @org.junit.Test(timeout = 3000)
    public void test_2() throws java.lang.Exception {
        int result = humaneval.buggy.ADD.add(2, 3);
        org.junit.Assert.assertEquals(
            result, 5
        );
    }

    @org.junit.Test(timeout = 3000)
    public void test_3() throws java.lang.Exception {
        int result = humaneval.buggy.ADD.add(5, 7);
        org.junit.Assert.assertEquals(
            result, 12
        );
    }

    @org.junit.Test(timeout = 3000)
    public void test_4() throws java.lang.Exception {
        int result = humaneval.buggy.ADD.add(7, 5);
        org.junit.Assert.assertEquals(
            result, 12
        );
    }
}

Current (Incorrect) Testing Failures Message:

Tests run: 5, Failures: 3, Errors: 0, Skipped: 0, Time elapsed: 0.032 s <<< FAILURE! - in humaneval.TEST_ADD
test_2(humaneval.TEST_ADD)  Time elapsed: 0 s  <<< FAILURE!
java.lang.AssertionError: expected:<3> but was:<5>
	at humaneval.TEST_ADD.test_2(TEST_ADD.java:23)

test_3(humaneval.TEST_ADD)  Time elapsed: 0 s  <<< FAILURE!
java.lang.AssertionError: expected:<7> but was:<12>
	at humaneval.TEST_ADD.test_3(TEST_ADD.java:31)

test_4(humaneval.TEST_ADD)  Time elapsed: 0 s  <<< FAILURE!
java.lang.AssertionError: expected:<7> but was:<12>
	at humaneval.TEST_ADD.test_4(TEST_ADD.java:39)

Correct Testing Failures Message:

Tests run: 5, Failures: 3, Errors: 0, Skipped: 0, Time elapsed: 0.032 s <<< FAILURE! - in humaneval.TEST_ADD
test_2(humaneval.TEST_ADD)  Time elapsed: 0 s  <<< FAILURE!
java.lang.AssertionError: expected:<5> but was:<3>
	at humaneval.TEST_ADD.test_2(TEST_ADD.java:23)

test_3(humaneval.TEST_ADD)  Time elapsed: 0 s  <<< FAILURE!
java.lang.AssertionError: expected:<12> but was:<7>
	at humaneval.TEST_ADD.test_3(TEST_ADD.java:31)

test_4(humaneval.TEST_ADD)  Time elapsed: 0 s  <<< FAILURE!
java.lang.AssertionError: expected:<12> but was:<7>
	at humaneval.TEST_ADD.test_4(TEST_ADD.java:39)
Lingua principale
Java
Stelle
22
Fork
3
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.