rspec/rules/S2186/java/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

46 lines
1.2 KiB
Plaintext

== Why is this an issue?
JUnit assertions should not be made from the ``++run++`` method of a ``++Runnable++``, because failed assertions result in ``++AssertionError++``s being thrown. If the error is thrown from a thread other than the one that ran the test, the thread will exit but the test won't fail.
=== Noncompliant code example
[source,java]
----
public void run() {
// ...
Assert.assertEquals(expected, actual); // Noncompliant
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Remove this assertion.
'''
== Comments And Links
(visible only on this page)
=== on 22 Oct 2014, 19:20:32 Ann Campbell wrote:
Note that Applicability is marked only for Tests
=== on 24 Nov 2014, 19:33:09 Nicolas Peru wrote:
I am guessing here and so the answer should probably part of the RSPEC : The run method is a run method of a Thread class ?
=== on 22 Apr 2015, 11:01:15 Ann Campbell wrote:
Since you're already implementing this [~nicolas.peru], I'm guessing it's okay.
=== on 22 Apr 2015, 11:20:20 Nicolas Peru wrote:
\[~ann.campbell.2]yes, more especially with the the mention of ``++Runnable++``
endif::env-github,rspecator-view[]