diff --git a/features/step_definitions/mezuro_steps.rb b/features/step_definitions/mezuro_steps.rb new file mode 100644 index 0000000..3af1b89 --- /dev/null +++ b/features/step_definitions/mezuro_steps.rb @@ -0,0 +1,14 @@ +Then /^I directly delete content with name "([^\"]*)" for testing purposes$/ do |content_name| + Article.find_by_name(content_name).destroy +end + +Then /^I should be at the url "([^\"]*)"$/ do |url| + if response.class.to_s == 'Webrat::SeleniumResponse' + URI.parse(response.selenium.get_location).path.should == url + else + URI.parse(current_url).path.should == url + end +end + +Then /^I don't fill anything$/ do +end diff --git a/plugins/mezuro/test/features/adding_metric_configuration.feature b/plugins/mezuro/test/features/adding_metric_configuration.feature new file mode 100644 index 0000000..4f8cc38 --- /dev/null +++ b/plugins/mezuro/test/features/adding_metric_configuration.feature @@ -0,0 +1,67 @@ +Feature: Add metric configuration to a configuration + As a mezuro user + I want to add metric configurations to a Kalibro configuration + + Background: + Given the following users + | login | name | + | joaosilva | Joao Silva | + And I am logged in as "joaosilva" + And "Mezuro" plugin is enabled + And the following community + | identifier | name | + | mycommunity | My Community | + And "Joao Silva" is admin of "My Community" + And I am on My Community's cms + And I create a content of type "Kalibro configuration" with the following data + | Title | My Configuration | + | Description | A sample description | + + Scenario: adding a native metric configuration + When I follow "Add metric" + And I follow "Analizo" + And I follow "Lines of Code" + And I fill in the following: + | Code: | Sample Code | + | Weight: | 10.0 | + And I select "Average" from "Aggregation Form:" + And I press "Add" + Then I should see "Lines of Code" + And I should see "Analizo" + And I should see "Sample Code" + + Scenario: adding a native metric configuration without code + When I follow "Add metric" + And I follow "Analizo" + And I follow "Number of Children" + And I don't fill anything + And I press "Add" + Then I should be at the url "/myprofile/my-community/plugin/mezuro/new_metric_configuration" + + Scenario: adding a compound metric configuration + When I follow "Add metric" + And I follow "New Compound Metric" + And I fill in the following: + | Name: | Compound sample | + | Description: | 10.0 | + | Script: | return 42; | + | Code: | anyCode | + | Weight: | 10.0 | + And I select "Class" from "Scope:" + And I select "Average" from "Aggregation Form:" + And I press "Add" + Then I should see "Compound sample" + + Scenario: adding a compound metric configuration with invalid script + When I follow "Add metric" + And I follow "New Compound Metric" + And I fill in the following: + | Name: | Compound sample | + | Description: | 10.0 | + | Script: | invalid script | + | Code: | anyCode | + | Weight: | 10.0 | + And I select "Class" from "Scope:" + And I select "Average" from "Aggregation Form:" + And I press "Add" + Then I should see "Compound sample" diff --git a/plugins/mezuro/test/features/adding_ranges.feature b/plugins/mezuro/test/features/adding_ranges.feature new file mode 100644 index 0000000..8af9f0c --- /dev/null +++ b/plugins/mezuro/test/features/adding_ranges.feature @@ -0,0 +1,42 @@ +Feature: Add range to a metric configuration + As a mezuro user + I want to add ranges to a Kalibro metric configuration + + Background: + Given the following users + | login | name | + | joaosilva | Joao Silva | + And I am logged in as "joaosilva" + And "Mezuro" plugin is enabled + And the following community + | identifier | name | + | mycommunity | My Community | + And "Joao Silva" is admin of "My Community" + And I am on My Community's cms + And I create a content of type "Kalibro configuration" with the following data + | Title | My Configuration | + | Description | A sample description | + And I follow "Add metric" + And I follow "Analizo" + And I follow "Lines of Code" + And I fill in the following: + | Code: | Sample Code | + | Weight: | 10.0 | + And I select "Average" from "Aggregation Form:" + And I press "Add" + Then I should see "Lines of Code" + And I should see "Analizo" + And I should see "Sample Code" + + Scenario: adding a range to a metric configuration + When I follow "New Range" and wait + And I fill in the following: + | (*) Label: | label | + | (*) Beginning: | 1 | + | (*) End: | 10 | + | (*) Grade: | 100 | + | (*) Color: | FFFF00FF | + | Comments: | Comentário | + And I press "Save Range" and wait + And I should see "label" within "#ranges" + diff --git a/plugins/mezuro/test/features/creating_configuration.feature b/plugins/mezuro/test/features/creating_configuration.feature index 3c48648..9146de0 100644 --- a/plugins/mezuro/test/features/creating_configuration.feature +++ b/plugins/mezuro/test/features/creating_configuration.feature @@ -1,4 +1,4 @@ -Feature: create configuration +Feature: Create configuration As a mezuro user I want to create a Kalibro configuration @@ -23,17 +23,18 @@ Feature: create configuration And I should see "Description" And I should see "A sample description" - Scenario: creating without title - Given I am on My Community's cms - When I create a content of type "Kalibro configuration" with the following data - | Title | | - Then I should see "1 error prohibited this {{model}} from being saved" - - Scenario: creating with duplicated title + Scenario: creating with duplicated name Given I am on My Community's cms And I create a content of type "Kalibro configuration" with the following data | Title | Original Title | And I am on My Community's cms When I create a content of type "Kalibro configuration" with the following data | Title | Original Title | - Then I should see "1 error prohibited this {{model}} from being saved" + Then I should see "1 error prohibited this article from being saved" + + Scenario: creating without title + Given I am on My Community's cms + When I create a content of type "Kalibro configuration" with the following data + | Title | | + Then I should see "1 error prohibited this article from being saved" + diff --git a/plugins/mezuro/test/features/creating_project.feature b/plugins/mezuro/test/features/creating_project.feature new file mode 100644 index 0000000..ad28b91 --- /dev/null +++ b/plugins/mezuro/test/features/creating_project.feature @@ -0,0 +1,55 @@ +Feature: Create project + As a mezuro user + I want to create a Kalibro project + + Background: + Given the following users + | login | name | + | joaosilva | Joao Silva | + And I am logged in as "joaosilva" + And "Mezuro" plugin is enabled + And the following community + | identifier | name | + | mycommunity | My Community | + And "Joao Silva" is admin of "My Community" + + Scenario: I see Kalibro project's input form + Given I am on My Community's cms + When I follow "New content" + And I follow "Kalibro project" + Then I should see "Title" + And I should see "License" + And I should see "Repository type" + And I should see "GIT" + And I should see "REMOTE_ZIP" + And I should see "REMOTE_TARBALL" + And I should see "SUBVERSION" + And I should see "Repository url" + And I should see "Configuration" + And I should see "Kalibro for Java" + + Scenario: I create a Kalibro project with valid attributes + Given I am on My Community's cms + When I create a content of type "Kalibro project" with the following data + | Title | Sample Project | + | License | GPL | + | Repository type | SUBVERSION | + | Repository url | https://qt-calculator.svn.sourceforge.net/svnroot/qt-calculator | + | Configuration | Kalibro for Java | + Then I should see "Sample Project" + And I should see "GPL" + And I should see "SUBVERSION" + And I should see "https://qt-calculator.svn.sourceforge.net/svnroot/qt-calculator" + And I should see "Kalibro for Java" + And I directly delete content with name "Sample Project" for testing purposes + + Scenario: I can't create a Kalibro project with invalid attributes + Given I am on My Community's cms + When I create a content of type "Kalibro project" with the following data + | Title | | + | License | GPL | + | Repository type | SUBVERSION | + | Repository url | | + | Configuration | Kalibro for Java | + Then I should see "Title can't be blank" + And I should see "Missing repository url" diff --git a/plugins/mezuro/test/features/echo_port_test.rb b/plugins/mezuro/test/features/echo_port_test.rb new file mode 100644 index 0000000..9ebdfd6 --- /dev/null +++ b/plugins/mezuro/test/features/echo_port_test.rb @@ -0,0 +1,90 @@ +require "test_helper" + +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/base_tool_fixtures" +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/configuration_fixtures" +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/module_result_fixtures" +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_result_fixtures" + +class EchoPortTest < ActiveSupport::TestCase + + def setup + @port = Kalibro::Client::Port.new('Echo') + address = YAML.load_file("#{RAILS_ROOT}/plugins/mezuro/service.yaml") + address['KalibroService'] = 'KalibroFake' + @port.service_address=(address); + end + + should 'echo base tool' do + test BaseToolFixtures.analizo, 'BaseTool' do |base_tool| + base_tool.name = "echo " + base_tool.name + end + end + + should 'echo configuration' do + test ConfigurationFixtures.kalibro_configuration, 'Configuration' do |configuration| + configuration.name = "echo " + configuration.name + end + end + + should 'echo metric configuration' do + test_metric_configuration(MetricConfigurationFixtures.amloc_configuration) + test_metric_configuration(MetricConfigurationFixtures.sc_configuration) + end + + should 'echo module result' do + test ModuleResultFixtures.create, 'ModuleResult' do |module_result| + module_result.module.name = "echo." + module_result.module.name + end + end + + should 'echo project' do + test(ProjectFixtures.qt_calculator, 'Project') do |project| + project.name = "echo " + project.name + end + end + + should 'echo project result' do + test(ProjectResultFixtures.qt_calculator, 'ProjectResult') do |project_result| + project_result.project.name = "echo " + project_result.project.name + end + end + + should 'echo raw project' do + project = ProjectFixtures.qt_calculator + echoed = @port.request(:echo_raw_project, {:project => project.to_hash})[:project] + project.name = "echo " + project.name + project.state = nil + project.error = nil + assert_equal project, Kalibro::Entities::Project.from_hash(echoed) + end + + should 'work with enums' do + test_granularity("METHOD", "CLASS") + test_granularity("CLASS", "PACKAGE") + test_granularity("PACKAGE", "PACKAGE") + test_granularity("APPLICATION", "APPLICATION") + end + + private + + def test_metric_configuration(fixture) + test fixture, 'MetricConfiguration' do |metric_configuration| + metric_configuration.code = "echo_" + metric_configuration.code + end + end + + def test(fixture, entity_name) + entity_symbol = entity_name.underscore.to_sym + request_body = {entity_symbol => fixture.to_hash} + echoed = @port.request("echo_#{entity_symbol}".to_sym, request_body)[entity_symbol] + yield fixture + entity_class = "Kalibro::Entities::#{entity_name}".constantize + assert_equal fixture, entity_class.from_hash(echoed) + end + + def test_granularity(granularity, parent) + body = {:granularity => granularity} + assert_equal parent, @port.request(:infer_parent_granularity, body)[:parent_granularity] + end + +end diff --git a/plugins/mezuro/test/features/editing_configuration.feature b/plugins/mezuro/test/features/editing_configuration.feature index e8ea0e0..07c79d1 100644 --- a/plugins/mezuro/test/features/editing_configuration.feature +++ b/plugins/mezuro/test/features/editing_configuration.feature @@ -16,16 +16,34 @@ Feature: editing a configuration And I create a content of type "Kalibro configuration" with the following data | Title | My Configuration | | Description | A sample description | - - Scenario: adding a metric configuration - When I follow "Add metric" + And I follow "Add metric" And I follow "Analizo" And I follow "Lines of Code" And I fill in the following: - | Code: | Sample Code | + | Code: | SampleCode | | Weight: | 10.0 | - And I select "Average" from "Aggregation:" + And I select "Average" from "Aggregation Form:" And I press "Add" + And I press "Save" and wait + + Scenario: Keep metrics after editing configuration + When I follow "Edit" within "article-actions" and wait + And I press "Save" Then I should see "Lines of Code" - And I should see "Analizo" - And I should see "Sample Code" + + #FIXME: Create new step for this scenario + Scenario: Check if title is edit-disabled + When I follow "Edit" within "article-actions" and wait + And I fill in the following: + | Title | Some Title | + And I press "Save" and wait + Then I should not see "Some Title" + + + Scenario: Check if description is edit-enabled + When I follow "Edit" within "article-actions" and wait + And I fill in the following: + | Description | Some Description | + And I press "Save" and wait + Then I should see "Some Description" + And I should see "Lines of Code" diff --git a/plugins/mezuro/test/features/mezuro.feature b/plugins/mezuro/test/features/mezuro.feature deleted file mode 100644 index 996445f..0000000 --- a/plugins/mezuro/test/features/mezuro.feature +++ /dev/null @@ -1,69 +0,0 @@ -Feature: mezuro content - As a noosfero user - I want to create a Kalibro project - - Background: - Given the following users - | login | name | - | joaosilva | Joao Silva | - And I am logged in as "joaosilva" - And "Mezuro" plugin is enabled - And the following community - | identifier | name | - | mycommunity | My Community | - And "Joao Silva" is admin of "My Community" - - Scenario: I see Kalibro project as an option to new content - Given I am on My Community's cms - When I follow "New content" - Then I should see "Kalibro project" - - Scenario: I see Kalibro project's input form - Given I am on My Community's cms - When I follow "New content" - And I follow "Kalibro project" - Then I should see "Title" - And I should see "License" - And I should see "Repository type" - And I should see "GIT" - And I should see "REMOTE_ZIP" - And I should see "REMOTE_TARBALL" - And I should see "SUBVERSION" - And I should see "Repository url" - And I should see "Configuration" - And I should see "Kalibro for Java" - - Scenario: I create a sample mezuro content - Given I am on My Community's cms - When I create a content of type "Kalibro project" with the following data - | Title | Sample project | - | License | BSD | - | Repository type | GIT | - | Repository url | git://example | - Then I should see "Sample project" - And I should see "Viewed one time" - And I should see "BSD" - - Scenario: I create a real mezuro content - Given I am on My Community's cms - When I create a content of type "Kalibro project" with the following data - | Title | Qt-Calculator | - | License | GPL 2.0 | - | Repository type | SUBVERSION | - | Repository url | https://qt-calculator.svn.sourceforge.net/svnroot/qt-calculator | - Then I should see "Qt-Calculator" - - Scenario: I see results from a real Kalibro project - Given I am on My Community's cms - When I create a content of type "Kalibro project" with the following data - | Title | Qt-Calculator | - | License | GPL | - | Repository type | SUBVERSION | - | Repository url | https://qt-calculator.svn.sourceforge.net/svnroot/qt-calculator | - | Configuration | Kalibro for Java | - Then I should see "Qt-Calculator" - And I should see "GPL" - And I should see "SUBVERSION" - And I should see "https://qt-calculator.svn.sourceforge.net/svnroot/qt-calculator" - And I should see "Kalibro for Java" - And I should see "Kalibro Service is loading the source code" diff --git a/plugins/mezuro/test/features/removing_metric_configuration.feature b/plugins/mezuro/test/features/removing_metric_configuration.feature new file mode 100644 index 0000000..88f635c --- /dev/null +++ b/plugins/mezuro/test/features/removing_metric_configuration.feature @@ -0,0 +1,32 @@ +Feature: Remove a metric configuration from a configuration + As a mezuro user + I want to remove metric configurations from a configuration + + Background: + Given the following users + | login | name | + | joaosilva | Joao Silva | + And I am logged in as "joaosilva" + And "Mezuro" plugin is enabled + And the following community + | identifier | name | + | mycommunity | My Community | + And "Joao Silva" is admin of "My Community" + And I am on My Community's cms + And I create a content of type "Kalibro configuration" with the following data + | Title | My Configuration | + | Description | A sample description | + When I follow "Add metric" + And I follow "Analizo" + And I follow "Lines of Code" + And I fill in the following: + | Code: | Sample Code | + | Weight: | 10.0 | + And I select "Average" from "Aggregation Form:" + And I press "Add" + And I press "Save" + And I should see "Lines of Code" + + Scenario: I remove a metric configuration + When I follow "Remove" + Then I should not see "Lines of Code" diff --git a/plugins/mezuro/test/functional/echo_port_test.rb b/plugins/mezuro/test/functional/echo_port_test.rb deleted file mode 100644 index e9ec887..0000000 --- a/plugins/mezuro/test/functional/echo_port_test.rb +++ /dev/null @@ -1,88 +0,0 @@ -require "test_helper" - -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/base_tool_fixtures" -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/configuration_fixtures" -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/module_result_fixtures" -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_result_fixtures" - -class EchoPortTest < ActiveSupport::TestCase - - def setup - @port = Kalibro::Client::Port.new('Echo') - @port.service_address=('http://valinhos.ime.usp.br:50688/KalibroFake/'); - end - - should 'echo base tool' do - test BaseToolFixtures.analizo, 'BaseTool' do |base_tool| - base_tool.name = "echo " + base_tool.name - end - end - - should 'echo configuration' do - test ConfigurationFixtures.kalibro_configuration, 'Configuration' do |configuration| - configuration.name = "echo " + configuration.name - end - end - - should 'echo metric configuration' do - test_metric_configuration(MetricConfigurationFixtures.amloc_configuration) - test_metric_configuration(MetricConfigurationFixtures.sc_configuration) - end - - should 'echo module result' do - test ModuleResultFixtures.create, 'ModuleResult' do |module_result| - module_result.module.name = "echo." + module_result.module.name - end - end - - should 'echo project' do - test(ProjectFixtures.qt_calculator, 'Project') do |project| - project.name = "echo " + project.name - end - end - - should 'echo project result' do - test(ProjectResultFixtures.qt_calculator, 'ProjectResult') do |project_result| - project_result.project.name = "echo " + project_result.project.name - end - end - - should 'echo raw project' do - project = ProjectFixtures.qt_calculator - echoed = @port.request(:echo_raw_project, {:project => project.to_hash})[:project] - project.name = "echo " + project.name - project.state = nil - project.error = nil - assert_equal project, Kalibro::Entities::Project.from_hash(echoed) - end - - should 'work with enums' do - test_granularity("METHOD", "CLASS") - test_granularity("CLASS", "PACKAGE") - test_granularity("PACKAGE", "PACKAGE") - test_granularity("APPLICATION", "APPLICATION") - end - - private - - def test_metric_configuration(fixture) - test fixture, 'MetricConfiguration' do |metric_configuration| - metric_configuration.code = "echo_" + metric_configuration.code - end - end - - def test(fixture, entity_name) - entity_symbol = entity_name.underscore.to_sym - request_body = {entity_symbol => fixture.to_hash} - echoed = @port.request("echo_#{entity_symbol}".to_sym, request_body)[entity_symbol] - yield fixture - entity_class = "Kalibro::Entities::#{entity_name}".constantize - assert_equal fixture, entity_class.from_hash(echoed) - end - - def test_granularity(granularity, parent) - body = {:granularity => granularity} - assert_equal parent, @port.request(:infer_parent_granularity, body)[:parent_granularity] - end - -end -- libgit2 0.21.2