-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Equipe 7] Casos de teste e correção de bug.
Implementação dos casos de teste relativos a feature Reports e correção da issue #85.
- Loading branch information
Showing
18 changed files
with
402 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
@i10n | ||
Feature: Reports | ||
I want to generate PDF, HTML or XML report files of Members and Research Groups | ||
|
||
Scenario: export member report to pdf | ||
Given I am at the Member list page | ||
When I select the "1" option at the Member list | ||
And I can select the option Export to PDF at the Member show | ||
Then I can generate a PDF report about Member "1" | ||
|
||
Scenario: export member report to html | ||
Given I am at the Member list page | ||
When I select the "1" option at the Member list | ||
And I can select the option Export to HTML at the Member show | ||
Then I can generate a HTML report about Member "1" | ||
|
||
Scenario: export member report to xml | ||
Given I am at the Member list page | ||
When I select the "1" option at the Member list | ||
And I can select the option Export to XML at the Member show | ||
Then I can generate a XML report about Member "1" | ||
|
||
Scenario: export research group report to pdf | ||
Given I am at the Research Group list page and I select the "testehugo1" group | ||
When I select the "testehugo1" option at the Research Group list | ||
And I can select the option Export to PDF at the Research Group show | ||
Then I can generate a PDF report about Research Group "testehugo1" | ||
|
||
Scenario: export research group report to html | ||
Given I am at the Research Group list page and I select the "testehugo12" group | ||
When I select the "testehugo12" option at the Research Group list | ||
And I can select the option Export to HTML at the Research Group show | ||
Then I can generate a HTML report about Research Group "testehugo12" | ||
|
||
Scenario: export research group report to xml | ||
Given I am at the Research Group list page and I select the "testehugo123" group | ||
When I select the "testehugo123" option at the Research Group list | ||
And I can select the option Export to XML at the Research Group show | ||
Then I can generate a XML report about Research Group "testehugo123" | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
import pages.LoginPage | ||
import pages.MemberListPage | ||
import pages.MemberPage | ||
|
||
import pages.PublicationsPage | ||
import pages.ResearchGroupListPage | ||
import pages.ResearchGroupPage | ||
|
||
import static cucumber.api.groovy.EN.* | ||
|
||
this.metaClass.mixin(cucumber.api.groovy.Hooks) | ||
this.metaClass.mixin(cucumber.api.groovy.EN) | ||
|
||
Given(~'^I am at the Member list page$') {-> | ||
to LoginPage | ||
at LoginPage | ||
page.fillLoginData("admin", "adminadmin") | ||
at PublicationsPage | ||
to MemberListPage | ||
at MemberListPage | ||
} | ||
|
||
When(~'^I select the "([^"]*)" option at the Member list$') { String memberName -> | ||
page.selectMember(memberName) | ||
} | ||
|
||
And(~'^I can select the option Export to PDF at the Member show$') { -> | ||
at MemberPage | ||
page.checkPdf() | ||
} | ||
|
||
Then(~'^I can generate a PDF report about Member "([^"]*)"$') { String memberName -> | ||
page.comparePDF(memberName) | ||
} | ||
//----------------------------------------------------------------------------------------------- | ||
/*Given(~'^I am at the Member list page$') { -> | ||
to LoginPage | ||
at LoginPage | ||
page.fillLoginData("admin", "adminadmin") | ||
at PublicationsPage | ||
to MemberListPage | ||
at MemberListPage | ||
} | ||
When(~'^I select the "([^"]*)" option at the Member list$') { String memberName -> | ||
page.selectMember(memberName) | ||
} */ | ||
|
||
And(~'^I can select the option Export to HTML at the Member show$') { -> | ||
at MemberPage | ||
page.checkHtml() | ||
} | ||
|
||
Then(~'^I can generate a HTML report about Member "([^"]*)"$') { String memberName -> | ||
page.compareHTML(memberName) | ||
} | ||
//------------------------------------------------------------------------------------------------- | ||
/*Given(~'^I am at the Member list page$') { -> | ||
to LoginPage | ||
at LoginPage | ||
page.fillLoginData("admin", "adminadmin") | ||
at PublicationsPage | ||
to MemberListPage | ||
at MemberListPage | ||
} | ||
When(~'^I select the "([^"]*)" option at the Member list$') { String memberName -> | ||
page.selectMember(memberName) | ||
} */ | ||
|
||
And(~'^I can select the option Export to XML at the Member show$') { -> | ||
at MemberPage | ||
page.checkXml() | ||
} | ||
|
||
Then(~'^I can generate a XML report about Member "([^"]*)"$') { String memberName -> | ||
page.compareXML(memberName) | ||
} | ||
//------------------------------------------------------------------------------------------------- | ||
Given(~'^I am at the Research Group list page and I select the "([^"]*)" group$') { String researchGroupName -> | ||
to LoginPage | ||
at LoginPage | ||
page.fillLoginData("admin", "adminadmin") | ||
at PublicationsPage | ||
to ResearchGroupListPage | ||
at ResearchGroupListPage | ||
} | ||
|
||
When(~'^I select the "([^"]*)" option at the Research Group list$') { String researchGroupName -> | ||
page.selectResearchGroup(researchGroupName) | ||
} | ||
|
||
And(~'^I can select the option Export to PDF at the Research Group show$') { -> | ||
at ResearchGroupPage | ||
page.checkPDF() | ||
} | ||
|
||
Then(~'^I can generate a PDF report about Research Group "([^"]*)"$') { String researchGroupName -> | ||
page.comparePDF(researchGroupName) | ||
} | ||
//------------------------------------------------------------------------------------------------- | ||
/*Given(~'^I am at the Research Group list page and I select the "([^"]*)" group$') { String researchGroupName -> | ||
to LoginPage | ||
at LoginPage | ||
page.fillLoginData("admin", "adminadmin") | ||
at PublicationsPage | ||
to ResearchGroupListPage | ||
at ResearchGroupListPage | ||
} | ||
/* | ||
When(~'^I select the "([^"]*)" option at the Research Group list$') { String researchGroupName -> | ||
page.selectResearchGroup(researchGroupName) | ||
} */ | ||
|
||
And(~'^I can select the option Export to HTML at the Research Group show$') { -> | ||
at ResearchGroupPage | ||
page.checkHtml() | ||
} | ||
|
||
Then(~'^I can generate a HTML report about Research Group "([^"]*)"$') { String researchGroupName -> | ||
page.compareHTML(researchGroupName) | ||
} | ||
//------------------------------------------------------------------------------------------------- | ||
/*Given(~'^I am at the Research Group list page and I select the "([^"]*)" group$') { String researchGroupName -> | ||
to LoginPage | ||
at LoginPage | ||
page.fillLoginData("admin", "adminadmin") | ||
at PublicationsPage | ||
to ResearchGroupListPage | ||
at ResearchGroupListPage | ||
} | ||
/* | ||
When(~'^I select the "([^"]*)" option at the Research Group list$') { String researchGroupName -> | ||
page.selectResearchGroup(researchGroupName) | ||
} */ | ||
|
||
And(~'^I can select the option Export to XML at the Research Group show$') { -> | ||
at ResearchGroupPage | ||
page.checkXml() | ||
} | ||
|
||
Then(~'^I can generate a XML report about Research Group "([^"]*)"$') { String researchGroupName -> | ||
page.compareXML(researchGroupName) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package pages | ||
|
||
import geb.Page | ||
|
||
class MemberListPage extends Page { | ||
static url = "member/list" | ||
|
||
static at = { | ||
title ==~ /Member Listagem/ | ||
} | ||
|
||
static content = { | ||
} | ||
|
||
def selectMember(String s) { | ||
$('div').find('a', text: s).click() | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package pages | ||
|
||
import com.itextpdf.text.pdf.PdfReader | ||
import geb.Page | ||
import com.itextpdf.text.pdf.parser.PdfTextExtractor | ||
import org.xml.sax.InputSource | ||
import rgms.member.Member | ||
|
||
import org.w3c.dom.*; | ||
import javax.xml.parsers.DocumentBuilder | ||
import javax.xml.parsers.DocumentBuilderFactory | ||
|
||
class MemberPage extends Page { | ||
static url = "member/show" | ||
|
||
static at = { | ||
title ==~ /Ver Member/ | ||
} | ||
|
||
static content = { | ||
} | ||
|
||
def checkPdf() { | ||
def pdf = $('form').find([title: "PDF"]) | ||
assert pdf != null | ||
} | ||
|
||
def checkHtml() { | ||
def html = $('form').find([title: "HTML"]) | ||
assert html != null | ||
} | ||
|
||
def checkXml() { | ||
def xml = $('form').find([title: "XML"]) | ||
assert xml != null | ||
} | ||
|
||
def comparePDF(String s) | ||
{ | ||
def downloadLink = $('form').find([title: "PDF"]).@href | ||
def bytes = downloadBytes(downloadLink) | ||
PdfReader reader = new PdfReader(bytes) | ||
def page = PdfTextExtractor.getTextFromPage(reader, 1) | ||
Member m = Member.findById(Integer.getInteger(s)) | ||
def name = page.find(m.name) | ||
def university = page.find(m.university) | ||
def email = page.find(m.email) | ||
assert name != null | ||
assert university != null | ||
assert email != null | ||
} | ||
|
||
def compareHTML(String s) | ||
{ | ||
def downloadLink = $('form').find([title: "PDF"]).@href | ||
def xml = new XmlSlurper() | ||
xml.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false) | ||
def parser = xml.parse(downloadLink) | ||
Member m = Member.findById(Integer.getInteger(s)) | ||
def name = parser.find(m.name) | ||
def university = parser.find(m.university) | ||
def email = parser.find(m.email) | ||
assert name != null | ||
assert university != null | ||
assert email != null | ||
} | ||
|
||
def compareXML(String s) | ||
{ | ||
def downloadLink = $('form').find([title: "XML"]).@href | ||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); | ||
DocumentBuilder db = dbf.newDocumentBuilder() | ||
Document doc = db.parse(downloadLink) | ||
Element langs = doc.getDocumentElement() | ||
NodeList list = langs.getElementsByTagName("name") | ||
Element name = (Element) list.item(0) | ||
NodeList list2 = langs.getElementsByTagName("university") | ||
Element university = (Element) list2.item(0) | ||
NodeList list3 = langs.getElementsByTagName("email") | ||
Element email = (Element) list3.item(0) | ||
Member m = Member.findById(Integer.getInteger(s)) | ||
assert name.textContent == m.name | ||
assert university.textContent == m.university | ||
assert email.textContent == m.email | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package pages | ||
|
||
import geb.Page | ||
|
||
class ResearchGroupListPage extends Page { | ||
static url = "researchGroup/list" | ||
|
||
static at = { | ||
title ==~ /Research Group Listagem/ | ||
} | ||
|
||
static content = { | ||
} | ||
|
||
def selectResearchGroup(String s) { | ||
$('div').find('a', text: s).click() | ||
} | ||
} |
Oops, something went wrong.