Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 83387 invoked from network); 4 Mar 2007 17:03:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Mar 2007 17:03:57 -0000 Received: (qmail 45370 invoked by uid 500); 4 Mar 2007 17:04:06 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 45301 invoked by uid 500); 4 Mar 2007 17:04:06 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 45288 invoked by uid 99); 4 Mar 2007 17:04:06 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Mar 2007 09:04:05 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS X-Spam-Check-By: apache.org Received: from [140.211.11.130] (HELO eos.apache.org) (140.211.11.130) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Mar 2007 09:03:56 -0800 Received: from eos.apache.osuosl.org (localhost [127.0.0.1]) by eos.apache.org (Postfix) with ESMTP id B21A359A05 for ; Sun, 4 Mar 2007 17:03:36 +0000 (GMT) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Apache Wiki To: derby-commits@db.apache.org Date: Sun, 04 Mar 2007 17:03:36 -0000 Message-ID: <20070304170336.28215.41336@eos.apache.osuosl.org> Subject: [Db-derby Wiki] Update of "JunitAssertMessages" by BryanPendleton X-Virus-Checked: Checked by ClamAV on apache.org Dear Wiki user, You have subscribed to a wiki page or wiki category on "Db-derby Wiki" for change notification. The following page has been changed by BryanPendleton: http://wiki.apache.org/db-derby/JunitAssertMessages The comment on the change is: Capture some notes from Dan New page: This style of code can be expensive at runtime: {{{ for (int i = 0; i < count; i++) { assertEquals("Testing at iteration " + i, f(i), g(i)); } }}} The issue is the message will be created 'count' times even though it is never used. This takes up cpu time and garbage collection time. In the Derby sanity code this style was a problem, causing extended test running time, so the encouraged practice (for Derby sanity checks) is {{{ if (SanityManager.ASSERT) { if (X != Y) SanityManager.THROWASSERT("Value should be " + X + " is " + Y); } }}} rather than {{{ if (SanityManager.ASSERT) { SanityManager.ASSERT(X == Y, "Value should be " + X + " is " + Y); } }}} We're still deciding what the best practice for JUnit tests should be, but based upon past experience when we see a loop with a complex iteration specific assert message we worry about execution time. In some cases the message can be fixed, e.g. this coding style should not be encouraged: {{{ assertEquals("Expected " + X + " to be the equal to " + Y, X, Y); }}} This is because the JUnit mechanism will print out the value of X and Y, so no need to repeat it in a generated message.