Test data generation tools supported by specflow - tdd

Is there any tool compatible with Specflow to generate test data. As in specflow while writing test scenarios you have to specify sample data as hard coded. Is there any tool which can generate test data for specflow test scenarios.
Thanks

If you would like to generate Test Data as Examples in Scenario Outline to treat each example as a separate unit test, it is not possible. But that's the point of BDD, you expect from each scenario to be well-described, and clear on what is happening there.
Given I have created user named <name>
When I try to login
Then user should access home page
Examples:
|name |
|Bob |
|Jack |
Depending on your case you can write steps to generate test data (in Backgroud on in the scenario itself) with any tool of your choice, and in another step check your requirements.
Given I have created 100 random users
When I try to login with each user
Then all users should access home page

Related

Common asserts in any automation project

Can anyone briefly explain what are the common asserts to consider in any automation project please. Whether it might be an in-house or public web application. For example presently i am using selenium (java) to automate an eCommerce web application. As this is my first website to automate, i am running out of ideas where i can verify things expect few which i know mentioned below:
1.Verify each page Title
2.Verify a button, text, link, image, custom text etc
Apart from these is there any thing else i can verify? please feel free to correct my question and if you have worked on various automation projects which areas did you add asserts to verify or validate something on a webpage.
basically, you do automation to decrease the execution time of regression cycles by automating the Test Cases relate to the functionality of the application. so, first develop test cases, using test design techniques like ECP, BVA etc.
Each test case must have an Assertion called expected result or functionality (otherwise it won't be called a Test case).
This assertion can be anything like,
Whether login successful after giving valid credentials
Showing an error message after entering wrong credentials etc.
Selenium helps us to automate web interactions (navigations, clicks, enter texts etc.) and don't perform any assertions for you.
Assertions are available by frameworks like JUnit, TestNG (in Java) with Assertions class. There is built-in support from programming languages like assert keyword in python & Java (http://docs.oracle.com/javase/7/docs/technotes/guides/language/assert.html)
So, whatever you mentioned in your question like common assertions (Verify each page Title etc.), those are just web interactions. they don't decide whether a Test is PASS or FAIL. It is you who define the criteria whether a Test is PASS/FAIL.
For example, there is a test case related to successful login.
here, you automate web interactions like navigate to login page, enter credentials, click Submit button.
Then to validate whether you successfully logged in or not, you look for a web element in the Home Page of the user logged in (like, welcome user) in normal scenario. In Automation, you try to find the text welcome user using webelement. Then you use Assertions provided by frameworks, to assert whether the expected message is present in the webpage like
Assertions.assertEqual(expected_message, actual_message); // just an example.
If expected_message and actual_message is same, then the method don't throw any exception, which results in marking the testcase as PASS by the framework
If expected_message and actual_message is NOT same, then AssertionError is raised by the method assertEqual, which results in marking the test case as FAIL by the framework.

Multiple feature inside single feature file

My current Cucumber file looks like this:
Feature: Test Online application Page
Scenario: Visit application home page and test links
Scenario: Visit application Login and Validate login
So now I would like to add few more scenarios may be for API testing in the same file. So i was thinking to create a new Feature for that instead of using the Feature: Test Online application Page. This way i dont need to create a separate feature file for API testing.
Feature: Test Online application Page
Scenario: Visit application home page and test links
Scenario: Visit application Login and Validate login
Feature: Test application API's
Scenario: validate Login API
Is it possible to have multiple features within a single feature file and is that a good practice? I just need to test one API and I will run API tests along with online tests. I will still separate them using #online and #api tags.
It is not possible to have multiple feature inside single feature file. If you create multiple feature inside single feature file, you will get Gherkin Parser exception while running cucumber scenarios. So the answer is NO.
C:/Users/ABC/RubymineProjects/XYZ.feature: Lexing error on line 47: 'Feature test google'. See https://github.com/cucumber-attic/gherkin2/wiki/LexingError for more information. (Cucumber::Core::Gherkin::ParseError)
Well, it is obviously not a good practice. It is best to put a single feature in a feature file. You should create new feature files for doing this. But you can add any number of scenarios in a single feature file.
The corresponding steps may or may not be in a single step file.
In BDD, cucumber is designed for the non-technical audience as well.
Writing scenario and steps definition in Gherkin Language or simple English is must support other audience.
All scenario should be executed Independently. No dependency on other scenario or feature file
In my past experience, Adding more complexity will add more flaky tests and High Maintenance cost
Agree with #philip John
You can create a text file with the features
and when executing the file it adds all the files in the order defined in the file.
#order-execution.txt
In this example, the file was created in the project root. file content
./features/records/country.feature
./features/records/company.feature
"scripts": {
"test:company": "cucumber-js #order-execution.txt --tags \"#company\" -f json:result/records/company.json",
},
this is the same as riding this way
"scripts": {
"company": "cucumber-js ./features/records/country.feature ./features/records/company.feature --tags \"#company\" -f json:result/records/company.json",
},

Questions about automation testing using Testcomplete

I'm working on a project regarding website test automation and I hope someone can help me with this question?
How would you recommend setting up some automated test processes that would not constantly need to be updated to test each of the core flows to test the following for a website:
login
register
sign in with facebook
save an item
delete an item
test that the few key pages (both logged in and logged out) are working like
Thanks in advance.
I'm not sure if I understand well.
But here is an instance of project setup.
Split your KeywordTest section into two folders:
A Test folder: it should contain all the KeywordTests that are called when you run your testsuite. Each of those KeywordTests should test a specific feature (Verify_Login_Fail, Verify_Login_Success...)
A Library folder: it should contain all your KeywordTests that are reusable and that might be used often from your Test folder KeywordTests. It's a kind of function library. It avoids code repetition and is easier to maintain.
For instance, you can create a KeywordTest that takes as parameter a Login and Password and that proceeds with the actions on your website to log a user in.
Store the sensible data (that might change often) in file or a database rather than hardcode it. For instance a file Login.csv where you store all the combination of login and password you want to test.
You have to write all the steps into in a class which should be in your library package and then you have to call all the methods from your test class of test package. You should use testng in your test class then create a testsuit of test class and run the script.

How to use jmeter using ant task - load testing on Dot Net application

I have just tried jmeter examples using ant task. I got the HTML output. Now,
I built my application using c#.net,asp.net,javascript,jQuery,Ajax,Json etc.
This is the url http://localhost/test/pagemanager.aspx which shows my
LOGIN Screen. Once after login, the user can access over multiple menus(pages) to access like checking their personal data, overall student details like batch wise, registering a new student etc... My URL http://localhost/test/pagemanager.aspxremains constant at every time.
The site can be accessed by multiple users for multiple times. I needs to find a load testing. Can some one give me a configuration step to find load testng to my application.
Thanks in advance.
First of all I would recommend recording your test scenario steps starting from login via JMeter build-in HTTP(S) Test Script Recorder.
See JMeter Proxy Step by Step guide for detailed instructions.
Once you have recorded test flow you'll need to do some correlation as the nature of ASP.NET applications assumes mandatory dynamic parameters like VIEWSTATE. So you'll need to extract VIEWSTATE and similar from previous server response and add it to next request.
See ASP.NET Login Testing with JMeter for more details.

ASP.NET MVC3 UI Unit Testing

I feel like I'm stuck in this political/religious battle. From the research I've done I've found that many people believe very strongly that UI testing is silly to do via unit testing and is something much better done by an actual person. I agree.
However it seems the higher-ups have told me to unit test the UI. (Which is already strange since they had previously told me I only had to write a test plan and not actual test). In all sincerity I'm not very familiar with unit testing. I'm trying to use MOQ but all the tutorials I find for it use repositories and not services and I'm structuring my web application around services.
As an example here is (a part of) a service:
public class ProductService : Service<Product, EntitiesDbContext>
{
...
public Product GetProduct(int id)
{
return All().FirstOrDefault(p => p.ProductId == id);
}
...
}
My assumption is that I need to create let's say, a new Product using Moq, and then someone validate the hard-coded input using my model. I'm not sure how to do this.
Testing the UI is the bulk of my work as the website relies heavily on user input via forms. Again I find it quite silly to test with unit testing since my models are very strict and only allow certain inputs.
To my question:
How would I go about testing form input using MOQ or possibly another testing framework?
I've heard that there are programs out there that can track your actions and then replicate them, but I've been unsuccessful in finding them and I also believe that such a technology would cost money.
Try Selenium or Watin for UI testing.
Visual Studio 2010 Ultimate has something called Coded UI test. Basically, you record your actions in Internet Explorer, which translate to C# code where you add assertions, and then you replay the actions in different browsers.
However, it is very difficult to test against a database backed web application, since you can hardly figure out which is the newly added row. To simplify matters, you might want to set up a sample database which will be reset to its initial state before running your test suite in sequence.
Take a look at the various TechEd videos on how to use Coded UI Test. E.g. http://www.youtube.com/watch?v=rZ8Q5EJ2bQM
Are you testing the Actions for your UI or are you testing Actual UI.
If you are testing the Actions and what data they are sending to the view then doing unit tests using something like NUnit, xUnit, etc and using a moq framework like MOQ or Rhino Mocks would be the right thing to do.
if you are testing the Actual UI(the HTML returned by the web server) then using an automated testing framework like Selenium would be the right tool
You can also try Ivonna (http://ivonna.biz) for MVC testing -- doesn't test your client side, but lets you test your Asp.Net server side code.
But first of all you should ask yourself (or your management) a question: what do I want to test? Client/server side validation? Your Service? Action Method?
There is a lot of opposition by developers to automate testing of the UI. What I did years ago was use "Selenium Core" This allowed me to fix do the testing in Firefox, then save out as C# , and then have a blend of C# and Html files in which I could have it do the following.
Forgot Password -- Automation random usernames from database would be entered and then encrypted passwords were emailed to various gmail accounts I set up and I had C# API to login to gmail and retrieve new reset password, then redirect and have application enter new password , and I could put this on a CI Server Hudson and automate this testing all day long, and logging of success and errors etc...
New Registration... similar to #1
So for your UI testing, lets call that Functional or UAT testing ...
Then for true Unit Testing, this is for NUnit / Xunit, MSTest etc... , and then MOQ etc... can assist.
Integration testing is truly testing of the entire application with connected systems... like a file system or WCF or Database , not being "mocked"
They all have their pros and cons and none of it is perfect, but most people end up saying Unit Testing is most bang for the buck.

Resources