Mhazad's Blog

January 6, 2010

Five Steps to SVN Merging

Filed under: Source Control, Subversion — Mahmudul Haque Azad @ 8:51 am

Few Points to ponder!

  • Always start on Green Light! i.e. start merging when both Trunk and Branch are fully committed and they are showing green color.
  • Merging always take place within a working copy i.e. in trunk.    
  • In every commit do not forget to add comment in the comment box. Mind it this is important!

 

Use Case for Merging

  • We have a main trunk
  • We have taken a branch named “CallForStandardFeedBack” branch.
  • After taking this branch, codes in both trunk and branch are modified by concerned developers.
  • Now we want to merge “CallForStandardFeedback” branch back to trunk and we have lots of changes both in trunk and merge.

Merging step: 1

  • All files are committed and we have green tick mark in our folder. Now we can start merging.

 

 

 

 

 

 

 

 

Merging step: 2

  • Right click on Trunk go to TortoiseSVN->Merge and Click Merge

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Merging step: 3

  • Select “Merge a range of revisions” and click next.

Merging Step 4

  • Select the value as appropriate in the picture below.


 

 

 

 

 

 

 

 

 

 

 

 

 

 

Explaining ??

  • Range Of Revision: Range of revision is actually all those range of changes that we want to merge with trunk. As we are merging a full branch with trunk so we will select all the ranges like below.


     

 

 

 

 

 

 

 

 

 

 

 

  • Reverse Merge: Reverse Merge is basically to decouple the changes the was committed with trunk before while merging one particular branch with trunk. Say for example we have implemented one menu in one branch and merged it with trunk. After few days it is needed to rollback every code related with that branch. In that case we will use reverse Merge.

Merge Step 5

  • Use the default value in this form and click merge to get the job done!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

After merging you will get the result like below. Now handle only conflicted files and do an integration test!

 

 

 

 

 

 

 

 

 

 

Happy Merging!

January 5, 2010

Database Driven Unit Testing Using VSTS

Filed under: ASP.NET, Software Testing, Visual Studio — Mahmudul Haque Azad @ 7:14 am

The primary concern about Database driven Unit testing is to maintain the test database intact. To elaborate suppose we have an add method that adds customer information in the database and we have a get method that actually returns a list of customer from database.

So we will have to different Unit test method for AddCustomer() and GetCustomer().

Now in order to pass the GetCustomer() method as a test case we have decided that it will return exactly 3 records and we have setup our test database in such a way to meet our test criterion.

The problem will be raised if we test the AddCustomer() method before GetCustomer() Method as AddCustomer() method will add one customer and our GetCustomer() Method will return 4 records that will fail its test case.

In order to overcome such situation we can use the power of TransactionScope Object.

In order to use this you must include System.Transactions in the Unit Test Project references and add System.Transactions in the reference section.

In the class generated by VSTS  Unit Test wizard you can see one region commented like below.


#region Additional test attributes

//

//You can use the following additional attributes as you write your tests:

//

//Use ClassInitialize to run code before running the first test in the class

//[ClassInitialize()]

//public static void MyClassInitialize(TestContext testContext)

//{

//}

//

//Use ClassCleanup to run code after all tests in a class have run

//[ClassCleanup()]

//public static void MyClassCleanup()

//{

//}

//

//Use TestInitialize to run code before running each test

//[TestInitialize()]

//public void MyTestInitialize()

//{

//}

//

//Use TestCleanup to run code after each test has run

//[TestCleanup()]

//public void MyTestCleanup()

//{

//}

//

#endregion

From here just uncomment MyTestInitialize() and MyTestCleanup() method.

Now Declare one global variable of TransactionScope Object write the body of the methods like below


TransactionScope ts;

///Use TestInitialize to run code before

///running each test

[TestInitialize()]

public
void MyTestInitialize()

{

ts = new
TransactionScope();

}

///Use TestCleanup to run code after

///each test has run

[TestCleanup()]

public
void MyTestCleanup()

{

ts.Dispose();

}


After this before executing any Unit Test method MyTestInitialize() method will be called where a new instances of TransactionScope will be created and and after executing the Unit test method the object will be disposed which will ultimately rollback all the changes committed by the Unit test Method keeping our test database intact.

Happy Testing!

Blog at WordPress.com.