question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

assertSame/assertNotSame broken after GITHUB-2296

See original GitHub issue

TestNG Version

7.4.0 (7.3.0 worked fine)

Expected behavior

assertSame(object.clone(), object) returns false

Actual behavior

assertSame(object.clone(), object) returns true

Description

assertSame/assertNotSame should use == operator, but not equals method to compare the same objects to identify they are the same object or different objects

Is the issue reproductible on runner?

  • Shell
  • Maven
  • Gradle
  • Ant
  • Eclipse
  • IntelliJ
  • NetBeans

Test case sample

public void testAssertNotSame() {
    Contrived object = new Contrived(2);
    Contrived object2 = new Contrived(2);;
    Assert.assertNotSame(object2, object);
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
Axinetcommented, Aug 16, 2021

Are there any plans to release 7.4.1 with this fix? Broken assertion seems like important enough part of test framework to release fix/patch?

0reactions
juherrcommented, Aug 23, 2021

I am still surprised that there is no patch planned

It is too much effort to deal with many branches. The fix will be included in the next release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

assertEquals doesn't work for sets · Issue #2296 · cbeust/testng
I implemented a fix but couldn't create a pull request, so here it is: add the following code in method org.testng.Assert#assertEquals( ...
Read more >
Broken assertSame/assertNotSame after #2460 #2616 - GitHub
Problem is present for any custom object which has implemented its own equals method. import java.util.Objects; import org.testng.Assert; import ...
Read more >
testng/CHANGES.txt at master · cbeust/testng - GitHub
Fixed: GITHUB-2486: assertSame/assertNotSame broken after GITHUB-2296 (Vitalii Diravka). Fixed: GITHUB-2490: assertNotEquals returns fast when argument is ...
Read more >
Breaking change of assertEquals(Object, Object) in TestNG ...
I am currently trying to upgrade TestNG to 7.0.0 and I found that version 6.9.4 changed the behavior of Assert.assertEquals . It was:...
Read more >
changes in behavior with assertEquals(Collection) et al #2540
Do you think it is feasible to run testng test subset in cbeust/testng GitHub Actions to validate that upcoming TestNG releases do not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found