Assertion « Test « Java Articles

Java Articles
1. Build Deploy
2. Class
3. Core Library
4. Data Types
5. Database JDBC
6. Design
7. Development
8. File Input Output
9. Graphics Desktop
10. J2EE Enterprise
11. J2ME Wireless
12. JVM
13. Language
14. Library Product
15. Network
16. Security
17. SOA Web Services
18. Test
19. Web Development
20. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Products
Java by API
Photoshop Tutorial
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Articles » Test » Assertion 
1. J2SE 1.4 premieres Java's assertion capabilities, Part 2
"Though a simple construct, assertions have broad implications on the approach to writing solid Java programs. Developers might aspire to create right programs, but attaining such an elusive and subjective quality actually proves quite difficult. What exactly is right, and what measures or metrics determine rightness? Those questions, of course, have no definitive answer, but the software engineering community does recognize and discuss software quality attributes. One such attribute is software reliability, and many of software engineering's best practices take direct aim at improving software products' reliability. In this article, I show how assertions deal with the reliability aspect known as correctness, which complements another reliability aspect, robustness. I also show the Java assertion facility to be but a small step toward a more complete and formal approach to reliability in software development known as Design by Contract."

2. J2SE 1.4 premieres Java's assertion capabilities, Part 1
"The method main() calls m1(int) twice, once with a positive value and once with a negative value. The call with the negative value triggers an assertion error. Since assert is a new Java keyword, to see this example in action, you must compile the class with a J2SE 1.4-compliant compiler. Furthermore, the compiler requires a command-line option, -source 1.4, to signal source compilation using the assertion facility. Requiring a command-line switch to include assertions purportedly protects backward compatibility."

3. Using Assertions in Java Technology
"These three roles collectively support what is called the design-by-contract model of programming, a model that is well supported by the Eiffel programming language. Java technology, on the other hand, doesn't have built-in support for the design-by-contract model of programming. In fact, the Java platform did not have built-in support for assertions until the release of J2SE 1.4."

4. trait Assertions in org.scalatest
"Note that the passed Class may represent any type, not just Throwable or one of its subclasses. In Scala, exceptions can be caught based on traits they implement, so it may at times make sense to pass in a class instance for a trait. If a class instance is passed for a type that could not possibly be used to catch an exception (such as String, for example), this method will complete abruptly with an AssertionError."

5. class Equalizer in org.scalatest.Assertions
"Given this code, the Scala compiler looks for an === method on class String, because that's the class of "hello". String doesn't define ===, so the compiler looks for an implicit conversion from String to something that does have an === method, and it finds the convertToEqualizer method. It then rewrites the code to this:"

6. Magic with Merlin: Working with assertions
"And there you have it. That's the Java 1.4 assertion facility. For tips on where to use assertions, see the Usage Notes section of the formal documentation pointed out in Resources. The key thing to remember when working with assertions is that they can be selectively enabled; therefore, they shouldn't have any side effects, short of timing differences."

7. Diagnosing Java code: Assertions and temporal logic in Java programming
"Temporal Rover, from Time Rover Inc., is a tool for processing temporal logic assertions in Java programs and generating valid Java code from the assertions. (See Resources.) The company also offers a tool, DBRover, that works over database tables."

8. Assertion Extensions for JUnit
"Assertion Extensions for JUnit (JUnitX), an extensions package for the JUnit framework, is available for download from alphaWorks (see Resources). It provides the required implementation of many common complex assertions. Rather than write a complex JUnit test case for an assertion, you can call a JUnitX method to make that assertion from the same context -- with no additional setup. JUnitX also asserts that it functions as documented by including its own JUnit self-test suite. This reassures you that JUnitX is making its assertion according to the JUnitX documentation; if a unit test fails, you know it's the software code unit that has failed, not the JUnitX test implementation asserting a false failure."

w_ww___._ja__va2___s._c_o__m___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.