Components of Framework: This framework is comprise of following name spaces:
Verification Name Space – This name space having class SPVerification, which contains all the methods to validate SharePoint objects to be tested e.g. verifying list schema, list items, user groups etc.
Setup Name Space – This name space having class SPSetup, which contains the methods to generate the test data for testing e.g. populating a list/library, uploading documents, setting up user groups, user etc.
Helper Classes – These classes are used by above name spaces and hidden from outside access. These classes have the method to provide data to Verification and setup methods.
Using SharePoint CSOM framework to test SharePoint application:
Download the DLLs included in the package.
Create a Test Project in Visual Studio 2010/2013
Add reference to all DLLs in the package to the test project.
Add Name Space for SharePoint Client API and Test Automation Framework:
C#
Edit|Remove
csharp
using Microsoft.VisualStudio.TestTools.UnitTesting;//Name Space for SharePoint Client APIusing Microsoft.SharePoint.Client;//Name Space for Frameworkusing Test.Automation.SharePointCOM.Verification;
using Microsoft.VisualStudio.TestTools.UnitTesting; //Name Space for SharePoint Client APIusing Microsoft.SharePoint.Client; //Name Space for Frameworkusing Test.Automation.SharePointCOM.Verification;
Use the framework classes and initialize the SharePoint Application Under test:
C#
Edit|Remove
csharp
//Function for setting up the SharePoint Site Under Test [TestInitialize] public void SetUp() { TestSite = "http://WebAppURL/sites/SiteCollection/TestSite"; Domain = "TestDomain"; UserName = "Administrator"; Password = "Password"; verifySite = new SPVerification(); Assert.IsTrue(verifySite.SetSiteUnderTest(TestSite, UserName, Password, Domain, testContextInstance)); }
//Function for setting up the SharePoint Site Under Test [TestInitialize] publicvoid SetUp() { TestSite = "http://WebAppURL/sites/SiteCollection/TestSite"; Domain = "TestDomain"; UserName = "Administrator"; Password = "Password"; verifySite = new SPVerification(); Assert.IsTrue(verifySite.SetSiteUnderTest(TestSite, UserName, Password, Domain, testContextInstance)); }
Add a test method in the unit test file to validate a list on a SharePoint Point site (In the framework each method return a true or false which should be used with asserts to check the pass or fail status of a test):
C#
Edit|Remove
csharp
/*Test Method to Verify the Expected list on a SharePoint Site mentioned in the SetUp (In test initialization method)*/ [DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "C:\\TestData\\TestSite\\SP-Lists.csv", "SP-Lists#csv", DataAccessMethod.Sequential), TestMethod] public void VerifySPLists() { string ListName =testContextInstance.DataRow[0].ToString(); Assert.IsTrue(verifySite.VerifyLibraryExists(ListName, testContextInstance)); }
/*Test Method to Verify the Expected list on a SharePoint Site mentioned in the SetUp (In test initialization method)*/ [DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "C:\\TestData\\TestSite\\SP-Lists.csv", "SP-Lists#csv", DataAccessMethod.Sequential), TestMethod] publicvoid VerifySPLists() { string ListName =testContextInstance.DataRow[0].ToString(); Assert.IsTrue(verifySite.VerifyLibraryExists(ListName, testContextInstance)); }
Run the test.
Analyze the result (Framework uses the Test Context to log the results, which is useful to log the bugs and understand where the issue is):
Help Files:
Please read the User Manual file for help and usage of the methods available in the library. This document having MSDN like stucture for using the library.