Created
May 22, 2020 19:04
-
-
Save rajaraodv/5b2dcb87b36aaaaf6c44796c8a2249d7 to your computer and use it in GitHub Desktop.
UFG Hackathon example reporter code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: This is just an example in Ruby. This shows how to print and also how to call that method. | |
# Feel free to change it to your language and framework needs | |
# Execute example: $ rspec hackathon.rb -f documentation | |
require 'rspec' | |
# A Helper to print the test result in the following format: | |
# Task: <Task Number>, Test Name: <Test Name>, DOM Id:: <id>, Browser: <Browser>, Viewport: <Width x Height>, Device<Device type>, Status: <Pass | Fail> | |
# | |
# Example: Task: 1, Test Name: Search field is displayed, DOM Id: DIV__customsear__41, Browser: Chrome, Viewport: 1200 x 700, Device: Laptop, Status: Pass | |
# | |
# @param task int - 1, 2 or 3 | |
# @param test_name. string - Something meaningful. E.g. 1.1 Search field is displayed | |
# @param dom_id string - DOM ID of the element | |
# @param comparison_result boolean - The result of comparing the "Expected" value and the "Actual" value. | |
# @return boolean - returns the same comparison result back so that it can be used for further Assertions in the test code. | |
# Get the browser, viewport and device info from a variable like below or from a file or environment variable. | |
BROWSER = "Firefox" | |
VIEWPORT = "1200X700" | |
DEVICE = "Laptop" | |
def hackathon_report(task, test_name, dom_id, comparison_result) | |
File.open("raditional-V1-TestResults.txt", "a") do |file| | |
comparison_result ? status = 'passed' : status = 'failed' | |
report_content = "Task: #{task}, Test Name: #{test_name}, DOM Id: #{dom_id}, Viewport: #{VIEWPORT}, Device: #{DEVICE}, Status: #{status}" | |
file.write("#{report_content}\n") | |
end | |
# returns the result so that it can be used for further Assertions in the test code. | |
comparison_result | |
end | |
describe 'Testing without Visual Testing' do | |
context 'Test Sample' do | |
search_field = "DIV__customsear__41" | |
search_icon = "DIV__customsear__42" | |
it { expect(hackathon_report(1, "Search field is displayed", search_field, false)).to eq true } | |
it { expect(hackathon_report(2, "Search icon is displayed", search_icon, true)).to eq true } | |
# This is a real example below of how you would use this. The comparison_result param is where you'll place the object you want to assert it's visual attribute. | |
# It's marked as xit to skip for now. | |
xit { expect(hackathon_report(2, "Search icon is displayed", search_icon, driver.find_element(:css, search_icon).displayed?)).to eq true } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment