2023-05-03 11:06:20 +02:00
== Why is this an issue?
2021-04-28 16:49:39 +02:00
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.
2021-04-28 18:08:03 +02:00
2023-05-03 11:06:20 +02:00
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,java]
2021-04-28 16:49:39 +02:00
----
public void run() {
// ...
Assert.assertEquals(expected, actual); // Noncompliant
}
----
2021-04-28 18:08:03 +02:00
2021-06-02 20:44:38 +02:00
2021-06-03 09:05:38 +02:00
ifdef::env-github,rspecator-view[]
2021-09-20 15:38:42 +02:00
'''
== Implementation Specification
(visible only on this page)
2023-05-25 14:18:12 +02:00
=== Message
Remove this assertion.
2021-09-20 15:38:42 +02:00
2021-06-08 15:52:13 +02:00
'''
2021-06-02 20:44:38 +02:00
== Comments And Links
(visible only on this page)
2023-05-25 14:18:12 +02:00
=== 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++``
2021-06-03 09:05:38 +02:00
endif::env-github,rspecator-view[]