Project

General

Profile

Plugin for Tests

Added by Riewert Holtermann over 13 years ago

Good morning.

Successfully I've been following the plugin-tutorial and now I want to start writing the plugin I need.

I want to create a plugin to organise all the testings we have got to do at work.
By creating, or watching an issue, there should be a list of the tests, which have to be done, before
the issue can be closed. (see the screenshot i posted / its not real i draw inside what i want to have)
One issue can have many tests, and also one test can belong to more than one issue.
Creating an extra modul is not the problem, but joining issue and tickets could be a little more
complicated. I think I need to establish an (n:m)-relation in the model, between issues and tests.
How can this be done, so that someone just takes my plugin, installs it and it works without modifying
the original redmine-code?

I would be thankfull for any ideas about this points.

Best Regards

Riewert


Replies (15)

RE: Plugin for Tests - Added by Pedro Gutierrez over 13 years ago

I haven't thought a lot about it but... wouldn't it be easier just to create a specific tracker named test

And then just relate each issue with the associated tests. And automatically each test is associated with the issues it tests. In this way you'd have the n:m relationship you're looking for

But again, it's just my first guess. Perhaps you're trying to do something else.

RE: Plugin for Tests - Added by Riewert Holtermann over 13 years ago

Yes, could be a solution, but then I have no possibility to work with this tests in my module.

I want to sort this tests in my module, so I can see, what has to be tested again, when I am
changing the firmware, the software or the hardware in my projects.
For now, we are organising our tests in Word-documents.....
So our testers have to think about every test, if they have to do it or not.
And before they test our systems not enough, they are testing really everything again.
For example, we just change our firmware of a product, and they are doing all tests again,
even if the tests have not been written for testing the firmware.
That is a lot of waisted time.

But thank you for your quick answer. I have to keep on searching...

RE: Plugin for Tests - Added by Felix Schäfer over 13 years ago

Riewert Holtermann wrote:

I think I need to establish an (n:m)-relation in the model, between issues and tests.
How can this be done, so that someone just takes my plugin, installs it and it works without modifying
the original redmine-code?

There are rails helpers for this, look for has_and_belongs_to_many. You'd also need to extend the core classes (I think at least the Issue model) to add support for this relation, and you will need to add a migration for the join table.

RE: Plugin for Tests - Added by Riewert Holtermann over 13 years ago

Thank you,

yes I know about the helpers, I would realize my project that way. My basic question was, if I could realize my plugin without extending the core-classes?

But I think, that my realization should not be possible without.

Thanks again.

RE: Plugin for Tests - Added by Felix Schäfer over 13 years ago

Riewert Holtermann wrote:

But I think, that my realization should not be possible without.

Probably not.

yes I know about the helpers, I would realize my project that way. My basic question was, if I could realize my plugin without extending the core-classes?

What's so bad about extending the core classes? You can do that from your plugin too, and thus distribute all those changes with the rest of you plugin.

RE: Plugin for Tests - Added by Riewert Holtermann over 13 years ago

Ok, when it is possible to extend the core classes from inside of my plugin, I would do it.
Can you please give me an example how I can extend a core class from my plugin?
If it takes too much time, please send me some topics, so I can read about it.

Thank you very much!

RE: Plugin for Tests - Added by Marco Gutsche over 13 years ago

Have you looked at redcase?
It is still in alpha stadium but maybe it'll help you.

RE: Plugin for Tests - Added by Pedro Gutierrez over 13 years ago

Marco Gutsche wrote:

Have you looked at redcase?
It is still in alpha stadium but maybe it'll help you.

Hi Marco, this plugin you mention.
I've tried their demo site but I don't know if the current version is still too alpha or if I just couln't figure out the purpose of the plugin. Or both.

I merely created a couple of test cases (without problem) and tried to allocate them to and execution suite (without success) in order to simulate an execution.

RE: Plugin for Tests - Added by Felix Schäfer over 13 years ago

Riewert Holtermann wrote:

Ok, when it is possible to extend the core classes from inside of my plugin, I would do it.
Can you please give me an example how I can extend a core class from my plugin?
If it takes too much time, please send me some topics, so I can read about it.

See Plugin_Internals.

RE: Plugin for Tests - Added by Eric Davis over 13 years ago

Riewert Holtermann wrote:

Ok, when it is possible to extend the core classes from inside of my plugin, I would do it.
Can you please give me an example how I can extend a core class from my plugin?
If it takes too much time, please send me some topics, so I can read about it.

Felix's link to Plugin_Internals is best for documentation.

I've been extending the Redmine core classes from my plugins since Redmine first got a plugin API. If you want code examples, look on my Github account for the most recently updated projects that start with "redmine". My extensions are in lib/ and named something like "patch".

Eric Davis

RE: Plugin for Tests - Added by Riewert Holtermann over 13 years ago

Hello again,

at first thank you all for your help.

I have been writing a lot for my plugin and now I had to use your help and particularly it works.
The part where I need your help again is the following one, because I don't find the error.
As written above I need a n:m-relation between the issues and my testsets. I can add an issue to
a testset, but I'm not able to remove it by now.

This is the part of my controller, which is responsible for this actions:
@
def add_remove_issues_to_testset
@testset = Testset.find(params[:id])
@issues = Issue.find(:all, :conditions=>{:project_id=>Herve Harster}, :order => 'ID')
@issues_assigned_to_testset = @testset.issues.find(:all)
end

def add_issue_to_testset
@testset = Testset.find(params[:testsetid])
@issue = Issue.find(params[:id])
@testset.issues << @issue
redirect_to :action => "add_remove_issues_to_testset", :id => @testset, :project_id => @project
end
def remove_issue_from_testset
testset = Testset.find(params[:testsetid])
@issue = Issue.find(params[:id])
@issue.testsets.delete(@testset)
redirect_to :action => "add_remove_issues_to_testset", :id => @testset, :project_id => @project
end

And here is the part of my view, where I try to use the actions:
@
<table>
<tr>
<th align="left" style="width:2%"><%= l(:label_ticket_id) ></th>
<th align="left"><
= l(:label_ticket_subject) ></th>
<th align="left" style="width:2
" nowrap><%= l(:label_ticket_remove) %></th>
</tr>

<% @issues_assigned_to_testset.each do |assigned_issue| >
<tr>
<td style="width:2
"><%= link_to h(assigned_issue.id), :controller => "issues", :action => "show", :id => assigned_issue.id%></td>
<td><%= link_to h(assigned_issue.subject), :controller => "issues", :action => "show", :id => assigned_issue.id%></td>
<td align="center" style="width:2%" nowrap><%= link_to (image_tag "false.png"), {:action => "remove_issue_from_testset", :id => assigned_issue.id, :testsetid => @testset.id, :project_id => Herve Harster} ></td>
</tr>
<
end %>
</table>

<br>

<h3><%= l(:label_avaiable_issues_to_testset) %></h3>

<table>
<tr>
<th align="left" style="width:2%"><%= l(:label_ticket_id) ></th>
<th align="left"><
= l(:label_ticket_subject) ></th>
<th align="left" style="width:2
"><%= l(:label_ticket_add) %></th>
</tr>

<% issues.each do |issue| %>
<tr>
<td style="width:2%"><%= link_to h(issue.id), :controller => "issues", :action => "show", :id => issue.id%></td>
<td><%= link_to h(issue.subject), :controller => "issues", :action => "show", :id => issue.id%></td>
<td align="center" style="width:2%" nowrap><%= link_to (image_tag "true.png"), {:action => "add_issue_to_testset", :id => issue.id, :testsetid => @testset.id, :project_id => @project} %></td>
</tr>
<% end %>
</table>

And at last here are the parts of my model:

class Testset < ActiveRecord::Base
unloadable
has_and_belongs_to_many :tests
has_and_belongs_to_many :issues
end

and the patch, I copied / modified, you suggested me to do:
@
require_dependency 'issue'

  1. Patches Redmine's Issues dynamically. Adds a relationship
  2. Issue has_and_belongs_to_many to Testset
    module IssuePatch
    def self.included(base) # :nodoc:
    base.extend(ClassMethods)

    base.send(:include, InstanceMethods)

    1. Same as typing in the class
      base.class_eval do
      unloadable # Send unloadable so it will not be unloaded in development
      has_and_belongs_to_many :testsets
    end

    end

    module ClassMethods

    end

    module InstanceMethods # Wraps the association to get the Testset subject. Needed for the # Query and filtering
    def testsets_subject
    unless self.testsets.nil?
    return self.testsets.subject
    end
    end
    end
    end

  1. Add module to Issue
    Issue.send(:include, IssuePatch)
    @

The relation you see in the part of my model between tests and testsets works fine.
Only the relation I try to code between issues and testsets makes some trouble.

I hope you can help me, and know where to help me.

Again, best regards

Riewert

RE: Plugin for Tests - Added by Riewert Holtermann over 13 years ago

I missed the error:

I get

undefined method `>>' for #<Class:0x65b6f38>

when I try to remove the issue from the testset

Thanks again.

RE: Plugin for Tests - Added by Riewert Holtermann over 13 years ago

I mean:

undefined method `testsets' for #<Issue:0xbc226c0>

....

(Sorry.)

RE: Plugin for Tests - Added by Maxim Novikov about 13 years ago

Hi, Marco. Here is the deal...

There are some problems with usability of Redcase plugin I suppose. And you are not the first one who didn't catch how to use it.
I can give you a hand and describe shortly how it can be used in the right way.

I won't tell about conceptual things of Redcase, just how you can try to use it on http://test.qaproject.net/ actually.

So... We go to that site and register there. It's quite simple and usual thing of great Redmine product.
After that we go to projects and create some one there (when we're doing this tracker 'Test case" has to be enabled, but it's by default).
Now let's go and create some test cases. It should be done as creating new issue with 'Test case' tracker. Let's create some of them in 'Progress' status (we'll see a bit later why we need this).

We can now open Test cases tab and see our test cases in Test suites tree (in .Unsorted sub-folder). And you can create some execution suites and environments. If you want to drag test cases from Test cases tree to some Execution suite you can do that only with test cases in 'Progress' status. They have green indicator instead of red one that all other states have.

Also if project is just created you can see the following text above those threes - "(There is no version for this project. If you need to execute test cases please create some one...)".
It means that if we'd like to do something else we should create some project versions. Let's do that! We go to the project settings and create there some version. If we go to Test cases tab now we can see three tabs there ('Management', 'Execution' and 'Report') instead of just one that we had earlier.

To execute test cases we need open 'Execution tab', select test cases there, enter execution info and then press 'save' button. And of cause we are able now open Report tab to see some results information.

I hope it hepls.
You can just log into test site (http://test.qaproject.net/) as user 'qaproject' with password 'qwerty12' to see what I explained you.

Pedro Gutierrez wrote:

Marco Gutsche wrote:

Have you looked at redcase?
It is still in alpha stadium but maybe it'll help you.

Hi Marco, this plugin you mention.
I've tried their demo site but I don't know if the current version is still too alpha or if I just couln't figure out the purpose of the plugin. Or both.

I merely created a couple of test cases (without problem) and tried to allocate them to and execution suite (without success) in order to simulate an execution.

RE: Plugin for Tests - Added by Adriano Ceccarelli over 11 years ago

Verify this - http://www.redmine.org/plugins/impasse

Is very good ! The best, simple and efficient

    (1-15/15)