[b]Vsts selenium - Кабринский Рдуард
<h1>Vsts selenium</h1>
<p>[youtube]</p>
Vsts selenium <a href="http://remmont.com">New new new</a> Vsts selenium
<h1>TDD with Selenium and Castle</h1>
<p>Feb 20, 2007 7 min read</p>
<h3>Introduction</h3>
<h3>Preparation</h3>
<blockquote><p>manage users (add new, delete, edit user details, list all)</p></blockquote>
<p>In this test case, each user will have a Full Name, a Username , a Password and an Email, all of which are mandatory.</p>
<h3>Basic TDD Steps</h3>
<p>Following typical TDD steps:</p>
<p><ol>
<li>Write the test</li>
<li>Make it fail</li>
<li>Write the code to make the test succeed</li>
<li>Refactor</li>
<li>Repeat and start at Step</li>
</ol>
</p>
<h3>The First Test</h3>
<h4>Related Sponsored Content</h4>
<h5> Digital Transformation Game Plan – Download Now (By O’Reilly) </h5>
<h4>Related Sponsor</h4>
<p><b>LaunchDarkly Feature Management Platform.</b> Dynamically control the availability of application features to your users. <b>Start Free Trial</b>.</p>
<p>The first test that should be written is a test to add a new user. Test Driven Development is a design technique rather than a testing technique, because when writing the test, we will define how the code/page will work, therefore design.</p>
<p>In order to be able to add a new user a simple form like this is sufficient:</p>
<p style="clear: both"> <img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/user10.png" /></p>
<p>For the functional test the developer needs to open up the add page (prepare stage), fill the fields and save (action stage) and to verify if the user was actually saved (verification stage of the project). In order to do that, the developer needs to update the page and add a new list with the users on the left side, where later the code can verify the user exists after clicking save.</p>
<h3>Selenium comes into Action</h3>
<p>For a task like this developers need a tool that can actually perform this action on their behalf. Selenium conveniently does this in a browser and this is an excellent open source tool, such that it can be modified to your own needs I necessary. Selenium provides web based functional tests, and also allows the tests to be written as simple html tests, providing an interpreter that runs those actions for the developer:</p>
<p style="clear: both"><img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/image1.jpg" /></p>
<p>The great news for developers who want to integrate their tests with a continuous integration tool is that they can write the tests in their own preferred language like C#, Java, VB.NET, Ruby, and Python using an extension of Selenium called Selenium RC.</p>
<p>Using Selenium RC, the .NET version of the test would look like:</p>
<p style="clear: both"><img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/code1.png" /></p>
<h3>Step 2, Making the Initial Test Fail</h3>
<p>At this stage the developer hasn't written any code, so the test should fail. First start the Selenium RC server (a small Java server that handles the Selenium commands and transmits them to the browser):</p>
<p style="clear: both"><img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/user1.png" /></p>
<p>Running the test fails as expected:</p>
<p style="clear: both"><img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/user2.png" /></p>
<p>This is a good sign as this means the test fails when it should. Otherwise the test wouldn't really test anything and would be worthless.</p>
<h3>Step 3, Write the Code</h3>
<p>On step 3 in the TDD steps, the developer needs to write the code. This means when run against the tests, the code should not fail. Next create the user controller, then view and run the test:</p>
<p style="clear: both"><img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/code2.png" /></p>
<p>Next create an empty add.vm and rerun the test:</p>
<p>Selenium.SeleniumException: ERROR: Element link=Add new user not found</p>
<p>at Selenium.HttpCommandProcessor.DoCommand(String command, String[] args) <br />at Selenium.DefaultSelenium.Click(String locator) <br />at MRProjectTest.Functionals.Selenium.ManageUsersTests.TestAddNewUser() in <br />ManageUsersTests.cs:line 34</p>
<p>Since the error says that it cannot find the elements on the page, we add them in add.vm:</p>
<p style="clear: both"><img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/user3.png" /></p>
<p style="clear: both"><img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/user4.png" /></p>
<p>. an error once again since it submits the content on the form to create.aspx and clicking the button on the page has not been implemented yet.</p>
<p>Next add the code to save the data:</p>
<p style="clear: both"><img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/code3.png" /></p>
<p>Now wait because there does not exist a user class, the list action or the database.</p>
<h3>TDD-ing the Layers under the Presentation Layer</h3>
<p>In order to build the code the developer needs to build it using 'test first'. Although in some cases this isn't really necessary since ActiveRecord is already quite well tested and it is also covered by the functional test. It is still demonstrated to show how far more complicated situations should be handled.</p>
<p>Below is the test, which is not a functional test but is an integration test, a unit test that also uses the database):</p>
<p style="clear: both"><img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/user5.png" /></p>
<p>Test if it fails. In fact it does even not compile so the first thing would be to create a User class, with empty methods to force the code to compile:</p>
<p style="clear: both"><img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/code4.png" /></p>
<p>Now, run the test:</p>
<p>Castle.ActiveRecord.Framework.ActiveRecordException: An ActiveRecord class (UserManagement.Model.User) was used but the framework seems not properly initialized. Did you forget about ActiveRecordStarter.Initialize() ?</p>
<p>at Castle.ActiveRecord.ActiveRecordBase.EnsureInitialized(Type type) <br />at Castle.ActiveRecord.ActiveRecordBase.Save(Object instance) <br />at Castle.ActiveRecord.ActiveRecordBase.Save() <br />at MRProjectTest.Database.UsersDataAccessTests.TestSaveNewUser() <br />in UserDataAccessTest.cs:line 23</p>
<p>The error indicates the User class is not initialized in ActiveRecord, for that instance adapt the test thus:</p>
<p style="clear: both"><img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/code5.png" /></p>
<p>Add the appropriate attributes for ActiveRecord and the constructors and by reruning the test. Now a corresponding database table is missing, but that is quickly remedied by adding the following line in the test:</p>
<blockquote><p>ActiveRecordStarter.CreateSchema();//create the database schema</p></blockquote>
<p>After running the test the database table was created, but there is still a problem:</p>
<p>at UserManagement.Model.User.Find(Int64 id) in User.cs:line 72 <br />at MRProjectTest.Database.UsersDataAccessTests.TestSaveNewUser() in <br />UserDataAccessTest.cs:line 41</p>
<p>Finish implementing the Find method in the User class:</p>
<p>Finally a database test that works!</p>
<h3>Top-Down TDD Approach</h3>
<p>Usually tests like this one aren't really required, for the two reasons mentioned earlier but it was also done so that the flow is understood in a test first vertical development environment for a n-tier application.</p>
<h3>Back to the Functional Test</h3>
<p>Now that the User class exists and the database access works, it is time to continue work on the presentation layer.</p>
<p style="clear: both"><img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/user6.png" /></p>
<p>Implement the list action and view:</p>
<p>Create a list.vm:</p>
<p style="clear: both"><img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/user_13_list.png" /></p>
<p>For the view a GridComponent could have been used. Now running the test the developer should see a working UI Test for the first time.</p>
<p style="clear: both"><img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/user7.png" /></p>
<h3>Edit functionality</h3>
<p>Next there is a need to add the edit user functionality to the site. The functionality will flow like this: on the list of users page each user will have an edit link, which once clicked upon will transfer the user to editing where the class can modify the user details. When the form is saved the user is sent back to the list. Now write the test:</p>
<p style="clear: both"><img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/code6.png" /></p>
<p>A User is added to the database so when the list page is opened, there is something to edit. There is still a problem. If the test is run twice the user will be inserted twice in the database. In order to avoid this potential error do the following:</p>
<p style="clear: both"><img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/code7.png" /></p>
<p>Running all the tests, the edit test now fails:</p>
<p>Selenium.SeleniumException: ERROR: Element link=Edit not found</p>
<p>at Selenium.HttpCommandProcessor.DoCommand(String command, String[] args) <br />at Selenium.DefaultSelenium.Click(String locator) <br />at MRProjectTest.Functionals.Selenium.ManageUsersTests.TestEditUser() in <br />ManageUsersTests.cs:line 28</p>
<p>To rectify this problem add the Edit link in the list.vm:</p>
<p style="clear: both"><img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/user_12_list.png" /></p>
<p>Edit the action in the controller:</p>
<p>Now edit the view for this action: edit.vm</p>
<p style="clear: both"><img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/user_11_edit.png" /></p>
<p>Since the value will be saved in the update action we'll also have:</p>
<p style="clear: both"><img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/user8.png" /></p>
<p><strong>Success!!</strong></p>
<h3>Begin Refactoring</h3>
<p>There are a few areas of opportunity for refactoring that can be made. First, the TestAddNew and TestEdit methods are almost similar and:</p>
<p style="clear: both"><img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/code8.png" /></p>
<p style="clear: both"><img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/code9.png" /></p>
<p>Running the tests, they should all still work. Now go further into the views, which have a similar problem: add.vm and edit.vm are almost identical. Separate the common part into _form.vm. Running the tests still confirms the fact that the application is passing tests:</p>
<p style="clear: both"><img src="https://www.infoq.com/articles/Tutorial-TDD-Selenium/articles/Tutorial-TDD-Selenium/en/resources/user8.png" /></p>
<p>For delete, use the same test first principles. For the data validations or any other functionality the user will be able to use, add new tests, then finish by adding the code to make them pass those tests.</p>
<h3>Conclusion</h3>
<p>This is an example of designing an application with TDD using a method called incremental architecture. In the actual architecture of the system the architect and developer need not take a month in advance for design. The architecture and design is constructed as the code is written and tested. In this manner changes are very easily made since continuous refactoring is done to the code to make it better, all provided by TDD principles and using 'test first'.</p>
<h2>Vsts selenium</h2>
<h3>Vsts selenium</h3>
<p>[youtube]</p>
Vsts selenium <a href="http://remmont.com">News new</a> Vsts selenium
<h4>Vsts selenium</h4>
TDD principals provide architects a way to quickly jump into active development early in the application development lifecycle. Dan Bunea demonstrates how TDD can be applied in .NET.
<h5>Vsts selenium</h5>
Vsts selenium <a href="http://remmont.com">Vsts selenium</a> Vsts selenium
SOURCE: <h6>Vsts selenium</h6> <a href="https://dev-ops.engineer/">Vsts selenium</a> Vsts selenium
#tags#[replace: -,-Vsts selenium] Vsts selenium#tags#
headline news