Cloud Foundry: Design and Architecture
Derek Collison discusses the goals, the design premises and patterns employed in creating the architecture of Cloud Foundry, VMware’s open source PaaS, unveiling internal architectural details.
The content has been bookmarked!
There was an error bookmarking this content! Please retry.
Posted by Jenni Konrad on Feb 10, 2012
tSQLt is a free, open-source framework for unit testing in SQL Server. By writing tSQLt test cases, developers can create fake tables and views based on production data, then compare expected versus actual results in testing. Tests are written in T-SQL, so they can be created directly in SQL Server Management Studio.
By using tSQLt, developers can have data created by the test case itself, rather than having to test against a copy of a production database or a separately-maintained test database. All tests are run within transactions, to help reduce cleanup work. tSQLt tests can be grouped together logically in database schema called test classes.
Installing the framework is simple; after downloading tSQLt, the user first needs to enable CLRs on the database:
EXEC sp_configure 'clr enabled', 1; RECONFIGURE;
Running the script Example.sql from the tSQLt folder will create a demo database. (To install tSQLt to another database, run ALTER DATABASE with SET TRUSTWORTHY ON.)
The next step is to set up a test class, which will contain multiple test cases. Again, this just creates a new schema:
EXEC tSQLt.NewTestClass 'AcceleratorTests'; GO
Once that's complete, test cases can be created; the following is an example. All test case names must start with 'test' and follow SQL Server stored procedure naming conventions. This example creates a test table, inserts values, and calls the function GetStatusMessage. The tSQLt function AssertEquals checks the expected versus actual results, and the test passes if they match.
CREATE PROCEDURE [AcceleratorTests].[test status message includes the number of particles] AS BEGIN --Assemble: Fake the Particle table to make sure it is empty and that constraints will not be a problem EXEC tSQLt.FakeTable 'Accelerator.Particle'; -- Put 3 test particles into the table INSERT INTO Accelerator.Particle (Id) VALUES (1); INSERT INTO Accelerator.Particle (Id) VALUES (2); INSERT INTO Accelerator.Particle (Id) VALUES (3); --Act: Call the GetStatusMessageFunction DECLARE @StatusMessage NVARCHAR(MAX); SELECT @StatusMessage = Accelerator.GetStatusMessage(); --Assert: Make sure the status message is correct EXEC tSQLt.AssertEqualsString 'The Accelerator is prepared with 3 particles.', @StatusMessage; END;
When the test case is run, results are displayed in text (or optionally, output in XML format):
+----------------------+ |Test Execution Summary| +----------------------+ |No|Test Case Name |Result +--+------------------------------------------------------------------------+-------+ |1|[AcceleratorTests].[test status message includes the number of particles]|Success| ------------------------------------------------------------------------------- Msg 50000, Level 16, State 10, Line 1 Test Case Summary: 1 test case(s) executed, 1 succeeded, 0 failed, 0 errored. -------------------------------------------------------------------------------
Once a number of test cases have been created within a test class, they can be run as a batch using EXEC tSQLt.RunAll. For more information on getting started with tSQLt, visit the tSQLt Tutorial.
For those who want to make SQL unit testing part of their continuous build process, tSQLt can be integrated with Cruise Control. As has been reported previously here on InfoQ, there is also a visual interface available for tSQLt called SQL Test. tSQLt is compatible with SQL Server 2005 SP2 and higher.
Introducing SQLFire: a memory-optimized, high performance SQL database
Automating Error Reporting for .NET Applications
Visual Studio vNext: ALM features for Agile Planning, Team Collaboration
Derek Collison discusses the goals, the design premises and patterns employed in creating the architecture of Cloud Foundry, VMware’s open source PaaS, unveiling internal architectural details.
Andrew Watson talks about the work of the OMG, where CORBA is alive and well (hint: in your car), UML and UML Profiles vs. custom Modeling languages, DDS and other middleware, and much more.
Sohil Shah discusses creating iPhone and Android enterprise mobile applications based on cloud services using the open source platform OpenMobster.
Paul Sanford presents the transformations supported by data throughout its life cycle, and how that can be better done with Splunk, an engine for monitoring and analyzing machine-generated data.
A common “best practice” for unit tests is to only write a one assertion in each test. I intend to question this advice by showing that multiple assertions per test are both necessary and beneficial.
John Rauser presents the architectural and technological evolution of Amazon retail websites starting with 1994 and ending with adopting Amazon Web Services.
Michael Stal discusses system architecture quality, how to avoid architectural erosion, how to deal with refactoring, and design principles for architecture evolution.
Every developer has had to integrate with another system, API or component. Tis article provides strategies to handle the change and for he separating system boundaries.
No comments
Watch Thread Reply