<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Xguo6</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Xguo6"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Xguo6"/>
	<updated>2026-07-21T02:12:05Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84820</id>
		<title>CSC/ECE 517 Spring 2014/final doc updated qyx</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84820"/>
		<updated>2014-04-29T14:48:20Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
=== Statistics ===&lt;br /&gt;
''Please note that the coverage generate by SimpleCov may be lower than expect due to the added fixtures.''&lt;br /&gt;
&lt;br /&gt;
; Overall (set of 6 tests) : 105 tests, 156 assertions, 2 failures, 3060 / 13457 LOC (22.74%) covered.&lt;br /&gt;
; Unit tests : 18 tests, 18 assertions, 0 failures&lt;br /&gt;
; Functional tests : 87 tests, 138 assertions, 2 failures (reasons of failures can be found in &amp;quot;Possible Bugs&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
Run &lt;br /&gt;
 rake test:prepare&lt;br /&gt;
before each action.&lt;br /&gt;
To run unit tests&lt;br /&gt;
 bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/unit/team_test.rb test/unit/course_team_test.rb test/unit/assignment_team_test.rb test/unit/team_user_test.rb&lt;br /&gt;
To run functional tests&lt;br /&gt;
 bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/functional/advertise_for_partner_controller_test.rb test/functional/teams_users_controller_test.rb&lt;br /&gt;
You can also run multiple tests&lt;br /&gt;
  bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/functional/teams_users_controller_test.rb test/functional/advertise_for_partner_controller_test.rb test/unit/course_team_test.rb test/unit/assignment_team_test.rb test/unit/team_test.rb test/unit/team_user_test.rb&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
=== assignment_team.rb &amp;amp; course_team.rb ===&lt;br /&gt;
* Both assignment_team class and course_team class are inherited from team class.&lt;br /&gt;
* These two classes have similar methods, which could be used to manage teams for assignment and course more effectively.&lt;br /&gt;
== Summary of Found Issues ==&lt;br /&gt;
=== Changes made to the class===&lt;br /&gt;
==== team.rb ==== &lt;br /&gt;
''Based on the discussion from the demo, the duplicated method was deleted instead of commented out''&lt;br /&gt;
* duplicated def get_participants was removed&lt;br /&gt;
** This is removed because the same method is defined again at line 20&lt;br /&gt;
* duplicated def self.generate_team_name() was removed&lt;br /&gt;
** This is removed because the same method is defined again at line 131&lt;br /&gt;
==== advertise_for_team_controller.rb ====&lt;br /&gt;
* def new was removed&lt;br /&gt;
** since it's empty, there is no need to keep the code there&lt;br /&gt;
&lt;br /&gt;
=== Possible Refactoring ===&lt;br /&gt;
==== team.rb ==== &lt;br /&gt;
* line 81 def self.create_node_object(name, parent_id)&lt;br /&gt;
** see the TODO at line 80, the method will not work.&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only assigning the team object&lt;br /&gt;
=== assignment_team.rb ===&lt;br /&gt;
* in &amp;quot;delete&amp;quot; method, before sign_up.each.destory, we need to make sure sign_up is not nil.&lt;br /&gt;
* in &amp;quot;email&amp;quot; method, a method named get_team_users is called but this method has no definition. We should define get_team_users somewhere or delete &amp;quot;email&amp;quot; method.&lt;br /&gt;
=== course_team.rb ===&lt;br /&gt;
* add_participant(course_id, user)method should belong to course rather than course_team. Delete this method.&lt;br /&gt;
* self.export_all_assignment_team_related_to_course(csv, parent_id, options)method should be deleted.&lt;br /&gt;
&lt;br /&gt;
=== Possible Bugs ===&lt;br /&gt;
==== team.rb ====&lt;br /&gt;
* def add_member(user, assignment_id) allow nil to be passed&lt;br /&gt;
** rails always raise runtime error when nil is passed. [[#unit/team_test.rb|Test: &amp;quot;add member for course should create teams user&amp;quot; ]]&lt;br /&gt;
* def randomize_all_by_parent passing wrong arguments&lt;br /&gt;
** The code is passing wrong arguments in line 124 for add_member, there should be 2 arguments. [[#unit/team_test.rb|Test: &amp;quot;randomize_all_by_parent&amp;quot; ]]&lt;br /&gt;
* def import_team_members passing wrong arguments&lt;br /&gt;
** it is calling add_member and passing nil for assignment_id, which will make rails raise error.[[#unit/team_test.rb|Test: &amp;quot;import team members successfully&amp;quot; ]]&lt;br /&gt;
==== assignment_team.rb ====&lt;br /&gt;
* def self.get_export_fields(options)&lt;br /&gt;
** when the option team_name =&amp;gt; false, the second element of the output array should be &amp;quot;Team members&amp;quot;. But from the test, it is &amp;quot;Assignment Name&amp;quot;. This is one failure from assignment_team_test.rb&lt;br /&gt;
* def add_participant(assignment_id, user)&lt;br /&gt;
** the AssignmentParticipant.count does not increase. This is another failure from assignment_team_test.rb.&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
'''However, all of the fixtures are required to be in the fixutre folder, otherwise it will raise error.'''&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
* questions.yml&lt;br /&gt;
* signed_up_users.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Concerns for Test Cases ==&lt;br /&gt;
&lt;br /&gt;
=== functional/teams_users_controller_test.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== unit/teams_users_test.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== functional/advertise_for_partner_controller_test.rb ===&lt;br /&gt;
*  # test &amp;quot;test update advertisement fail&amp;quot; do&lt;br /&gt;
** should show flash for fail message when team.save fail, but there is no really a good way to fail team.save, so this is not implemented&lt;br /&gt;
&lt;br /&gt;
=== unit/team_test.rb ===&lt;br /&gt;
Most of test should be straightforward, so only the test with concerns will be listed below&lt;br /&gt;
*  test &amp;quot;get_participants from assignment team&amp;quot; do&lt;br /&gt;
** Please notice that this will actually call the get_participants under AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
*  test &amp;quot;generate_team_name&amp;quot; do&lt;br /&gt;
** Please notice that this method (self.generate_team_name)is modified&lt;br /&gt;
&lt;br /&gt;
*  test &amp;quot;add member for course should create teams user&amp;quot; do&lt;br /&gt;
** In the original code, it allow nil to be passed as parameter, and checks for assignment_id = nil, but rails will actually raise runtime error when nil is passed.&lt;br /&gt;
&lt;br /&gt;
*  #test &amp;quot;randomize_all_by_parent&amp;quot; do&lt;br /&gt;
** Commented out because the bug in the code make it raise error because assignment id not passed. (wrong argument)&lt;br /&gt;
&lt;br /&gt;
*  #test &amp;quot;import team members successfully&amp;quot; do&lt;br /&gt;
** problem: add_member are not passing correct assignment id in team.rb&lt;br /&gt;
&lt;br /&gt;
=== unit/assignment_team_test.rb ===&lt;br /&gt;
Because most of the tests are straightforward, only tests with concerns are listed.&lt;br /&gt;
* delete&lt;br /&gt;
** this method has bug. In the method, before sign_up.each.destory, we need to make sure sign_up is not nil. No test&lt;br /&gt;
* email&lt;br /&gt;
** this method has bug because there is no method named get_team_users. No test&lt;br /&gt;
&lt;br /&gt;
=== unit/course_team_test.rb ===&lt;br /&gt;
Only tests with concerns are listed.&lt;br /&gt;
*add_participant(course_id, user)&lt;br /&gt;
** this method should belong to course rather than course_team. This test may be not useful.&lt;br /&gt;
* self.export_all_assignment_team_related_to_course(csv, parent_id, options)&lt;br /&gt;
** this method should be deleted from course_team class. No test&lt;br /&gt;
&lt;br /&gt;
== Possible Refactoring ==&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participants_controller.rb ===&lt;br /&gt;
* These two files are never used, no tests will cover them.&lt;br /&gt;
&lt;br /&gt;
=== teams_user.rb ===&lt;br /&gt;
* In ''delete'' method, the statements about ''team.delete'' should be commented out due to the recursion it causes.&lt;br /&gt;
* ''elf.is_team_empty'' method is rewritten since the original code will cause fatal error.&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
* ''delete_select'' method will not work since the params are not in accordance with the method called inside.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84818</id>
		<title>CSC/ECE 517 Spring 2014/final doc updated qyx</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84818"/>
		<updated>2014-04-29T14:46:30Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
=== Statistics ===&lt;br /&gt;
''Please note that the coverage generate by SimpleCov may be lower than expect due to the added fixtures.''&lt;br /&gt;
&lt;br /&gt;
; Overall (set of 6 tests) : 105 tests, 156 assertions, 2 failures, 3060 / 13457 LOC (22.74%) covered.&lt;br /&gt;
; Unit tests : 18 tests, 18 assertions, 0 failures&lt;br /&gt;
; Functional tests : 87 tests, 138 assertions, 2 failures (reasons of failures can be found in &amp;quot;Possible Bugs&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
Run &lt;br /&gt;
 rake test:prepare&lt;br /&gt;
before each action.&lt;br /&gt;
To run unit tests&lt;br /&gt;
 bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/unit/team_test.rb test/unit/course_team_test.rb test/unit/assignment_team_test.rb test/unit/team_user_test.rb&lt;br /&gt;
To run functional tests&lt;br /&gt;
 bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/functional/advertise_for_partner_controller_test.rb test/functional/teams_users_controller_test.rb&lt;br /&gt;
You can also run multiple tests&lt;br /&gt;
  bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/functional/teams_users_controller_test.rb test/functional/advertise_for_partner_controller_test.rb test/unit/course_team_test.rb test/unit/assignment_team_test.rb test/unit/team_test.rb test/unit/team_user_test.rb&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
=== assignment_team.rb &amp;amp; course_team.rb ===&lt;br /&gt;
* Both assignment_team class and course_team class are inherited from team class.&lt;br /&gt;
* These two classes have similar methods, which could be used to manage teams for assignment and course more effectively.&lt;br /&gt;
== Summary of Found Issues ==&lt;br /&gt;
=== Changes made to the class===&lt;br /&gt;
==== team.rb ==== &lt;br /&gt;
''Based on the discussion from the demo, the duplicated method was deleted instead of commented out''&lt;br /&gt;
* duplicated def get_participants was removed&lt;br /&gt;
** This is removed because the same method is defined again at line 20&lt;br /&gt;
* duplicated def self.generate_team_name() was removed&lt;br /&gt;
** This is removed because the same method is defined again at line 131&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* def new was removed&lt;br /&gt;
** since it's empty, there is no need to keep the code there&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Possible Refactoring ===&lt;br /&gt;
==== team.rb ==== &lt;br /&gt;
* line 81 def self.create_node_object(name, parent_id)&lt;br /&gt;
** see the TODO at line 80, the method will not work.&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only assigning the team object&lt;br /&gt;
=== assignment_team.rb ===&lt;br /&gt;
* in &amp;quot;delete&amp;quot; method, before sign_up.each.destory, we need to make sure sign_up is not nil.&lt;br /&gt;
* in &amp;quot;email&amp;quot; method, a method named get_team_users is called but this method has no definition. We should define get_team_users somewhere or delete &amp;quot;email&amp;quot; method.&lt;br /&gt;
=== course_team.rb ===&lt;br /&gt;
* add_participant(course_id, user)method should belong to course rather than course_team. Delete this method.&lt;br /&gt;
* self.export_all_assignment_team_related_to_course(csv, parent_id, options)method should be deleted.&lt;br /&gt;
&lt;br /&gt;
=== Possible Bugs ===&lt;br /&gt;
==== team.rb ====&lt;br /&gt;
* def add_member(user, assignment_id) allow nil to be passed&lt;br /&gt;
** rails always raise runtime error when nil is passed. [[#unit/team_test.rb|Test: &amp;quot;add member for course should create teams user&amp;quot; ]]&lt;br /&gt;
* def randomize_all_by_parent passing wrong arguments&lt;br /&gt;
** The code is passing wrong arguments in line 124 for add_member, there should be 2 arguments. [[#unit/team_test.rb|Test: &amp;quot;randomize_all_by_parent&amp;quot; ]]&lt;br /&gt;
* def import_team_members passing wrong arguments&lt;br /&gt;
** it is calling add_member and passing nil for assignment_id, which will make rails raise error.[[#unit/team_test.rb|Test: &amp;quot;import team members successfully&amp;quot; ]]&lt;br /&gt;
==== assignment_team.rb ====&lt;br /&gt;
* def self.get_export_fields(options)&lt;br /&gt;
** when the option team_name =&amp;gt; false, the second element of the output array should be &amp;quot;Team members&amp;quot;. But from the test, it is &amp;quot;Assignment Name&amp;quot;. This is one failure from assignment_team_test.rb&lt;br /&gt;
* def add_participant(assignment_id, user)&lt;br /&gt;
** the AssignmentParticipant.count does not increase. This is another failure from assignment_team_test.rb.&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
'''However, all of the fixtures are required to be in the fixutre folder, otherwise it will raise error.'''&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
* questions.yml&lt;br /&gt;
* signed_up_users.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Concerns for Test Cases ==&lt;br /&gt;
&lt;br /&gt;
=== functional/teams_users_controller_test.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== unit/teams_users_test.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== functional/advertise_for_partner_controller_test.rb ===&lt;br /&gt;
*  # test &amp;quot;test update advertisement fail&amp;quot; do&lt;br /&gt;
** should show flash for fail message when team.save fail, but there is no really a good way to fail team.save, so this is not implemented&lt;br /&gt;
&lt;br /&gt;
=== unit/team_test.rb ===&lt;br /&gt;
Most of test should be straightforward, so only the test with concerns will be listed below&lt;br /&gt;
*  test &amp;quot;get_participants from assignment team&amp;quot; do&lt;br /&gt;
** Please notice that this will actually call the get_participants under AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
*  test &amp;quot;generate_team_name&amp;quot; do&lt;br /&gt;
** Please notice that this method (self.generate_team_name)is modified&lt;br /&gt;
&lt;br /&gt;
*  test &amp;quot;add member for course should create teams user&amp;quot; do&lt;br /&gt;
** In the original code, it allow nil to be passed as parameter, and checks for assignment_id = nil, but rails will actually raise runtime error when nil is passed.&lt;br /&gt;
&lt;br /&gt;
*  #test &amp;quot;randomize_all_by_parent&amp;quot; do&lt;br /&gt;
** Commented out because the bug in the code make it raise error because assignment id not passed. (wrong argument)&lt;br /&gt;
&lt;br /&gt;
*  #test &amp;quot;import team members successfully&amp;quot; do&lt;br /&gt;
** problem: add_member are not passing correct assignment id in team.rb&lt;br /&gt;
&lt;br /&gt;
=== unit/assignment_team_test.rb ===&lt;br /&gt;
Because most of the tests are straightforward, only tests with concerns are listed.&lt;br /&gt;
* delete&lt;br /&gt;
** this method has bug. In the method, before sign_up.each.destory, we need to make sure sign_up is not nil. No test&lt;br /&gt;
* email&lt;br /&gt;
** this method has bug because there is no method named get_team_users. No test&lt;br /&gt;
&lt;br /&gt;
=== unit/course_team_test.rb ===&lt;br /&gt;
Only tests with concerns are listed.&lt;br /&gt;
*add_participant(course_id, user)&lt;br /&gt;
** this method should belong to course rather than course_team. This test may be not useful.&lt;br /&gt;
* self.export_all_assignment_team_related_to_course(csv, parent_id, options)&lt;br /&gt;
** this method should be deleted from course_team class. No test&lt;br /&gt;
&lt;br /&gt;
== Possible Refactoring ==&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participants_controller.rb ===&lt;br /&gt;
* These two files are never used, no tests will cover them.&lt;br /&gt;
&lt;br /&gt;
=== teams_user.rb ===&lt;br /&gt;
* In ''delete'' method, the statements about ''team.delete'' should be commented out due to the recursion it causes.&lt;br /&gt;
* ''elf.is_team_empty'' method is rewritten since the original code will cause fatal error.&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
* ''delete_select'' method will not work since the params are not in accordance with the method called inside.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84817</id>
		<title>CSC/ECE 517 Spring 2014/final doc updated qyx</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84817"/>
		<updated>2014-04-29T14:39:40Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: /* Statistics */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
=== Statistics ===&lt;br /&gt;
''Please note that the coverage generate by SimpleCov may be lower than expect due to the added fixtures.''&lt;br /&gt;
&lt;br /&gt;
; Overall (set of 6 tests) : 105 tests, 156 assertions, 2 failures, 3060 / 13457 LOC (22.74%) covered.&lt;br /&gt;
; Unit tests : 18 tests, 18 assertions, 0 failures&lt;br /&gt;
; Functional tests : 87 tests, 138 assertions, 2 failures (reasons of failures can be found in &amp;quot;Possible Bugs&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
Run &lt;br /&gt;
 rake test:prepare&lt;br /&gt;
before each action.&lt;br /&gt;
To run unit tests&lt;br /&gt;
 bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/unit/team_test.rb test/unit/course_team_test.rb test/unit/assignment_team_test.rb test/unit/team_user_test.rb&lt;br /&gt;
To run functional tests&lt;br /&gt;
 bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/functional/advertise_for_partner_controller_test.rb test/functional/teams_users_controller_test.rb&lt;br /&gt;
You can also run multiple tests&lt;br /&gt;
  bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/functional/teams_users_controller_test.rb test/functional/advertise_for_partner_controller_test.rb test/unit/course_team_test.rb test/unit/assignment_team_test.rb test/unit/team_test.rb test/unit/team_user_test.rb&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
=== assignment_team.rb &amp;amp; course_team.rb ===&lt;br /&gt;
* Both assignment_team class and course_team class are inherited from team class.&lt;br /&gt;
* These two classes have similar methods, which could be used to manage teams for assignment and course more effectively.&lt;br /&gt;
== Summary of Found Issues ==&lt;br /&gt;
=== Changes made to the class===&lt;br /&gt;
==== team.rb ==== &lt;br /&gt;
''Based on the discussion from the demo, the duplicated method was deleted instead of commented out''&lt;br /&gt;
* duplicated def get_participants was removed&lt;br /&gt;
** This is removed because the same method is defined again at line 20&lt;br /&gt;
* duplicated def self.generate_team_name() was removed&lt;br /&gt;
** This is removed because the same method is defined again at line 131&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* def new was removed&lt;br /&gt;
** since it's empty, there is no need to keep the code there&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Possible Refactoring ===&lt;br /&gt;
==== team.rb ==== &lt;br /&gt;
* line 81 def self.create_node_object(name, parent_id)&lt;br /&gt;
** see the TODO at line 80, the method will not work.&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only assigning the team object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Possible Bugs ===&lt;br /&gt;
==== team.rb ====&lt;br /&gt;
* def add_member(user, assignment_id) allow nil to be passed&lt;br /&gt;
** rails always raise runtime error when nil is passed. [[#unit/team_test.rb|Test: &amp;quot;add member for course should create teams user&amp;quot; ]]&lt;br /&gt;
* def randomize_all_by_parent passing wrong arguments&lt;br /&gt;
** The code is passing wrong arguments in line 124 for add_member, there should be 2 arguments. [[#unit/team_test.rb|Test: &amp;quot;randomize_all_by_parent&amp;quot; ]]&lt;br /&gt;
* def import_team_members passing wrong arguments&lt;br /&gt;
** it is calling add_member and passing nil for assignment_id, which will make rails raise error.[[#unit/team_test.rb|Test: &amp;quot;import team members successfully&amp;quot; ]]&lt;br /&gt;
==== assignment_team.rb ====&lt;br /&gt;
* def self.get_export_fields(options)&lt;br /&gt;
** when the option team_name =&amp;gt; false, the second element of the output array should be &amp;quot;Team members&amp;quot;. But from the test, it is &amp;quot;Assignment Name&amp;quot;. This is one failure from assignment_team_test.rb&lt;br /&gt;
* def add_participant(assignment_id, user)&lt;br /&gt;
** the AssignmentParticipant.count does not increase. This is another failure from assignment_team_test.rb.&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
'''However, all of the fixtures are required to be in the fixutre folder, otherwise it will raise error.'''&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
* questions.yml&lt;br /&gt;
* signed_up_users.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Concerns for Test Cases ==&lt;br /&gt;
&lt;br /&gt;
=== functional/teams_users_controller_test.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== unit/teams_users_test.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== functional/advertise_for_partner_controller_test.rb ===&lt;br /&gt;
*  # test &amp;quot;test update advertisement fail&amp;quot; do&lt;br /&gt;
** should show flash for fail message when team.save fail, but there is no really a good way to fail team.save, so this is not implemented&lt;br /&gt;
&lt;br /&gt;
=== unit/team_test.rb ===&lt;br /&gt;
Most of test should be straightforward, so only the test with concerns will be listed below&lt;br /&gt;
*  test &amp;quot;get_participants from assignment team&amp;quot; do&lt;br /&gt;
** Please notice that this will actually call the get_participants under AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
*  test &amp;quot;generate_team_name&amp;quot; do&lt;br /&gt;
** Please notice that this method (self.generate_team_name)is modified&lt;br /&gt;
&lt;br /&gt;
*  test &amp;quot;add member for course should create teams user&amp;quot; do&lt;br /&gt;
** In the original code, it allow nil to be passed as parameter, and checks for assignment_id = nil, but rails will actually raise runtime error when nil is passed.&lt;br /&gt;
&lt;br /&gt;
*  #test &amp;quot;randomize_all_by_parent&amp;quot; do&lt;br /&gt;
** Commented out because the bug in the code make it raise error because assignment id not passed. (wrong argument)&lt;br /&gt;
&lt;br /&gt;
*  #test &amp;quot;import team members successfully&amp;quot; do&lt;br /&gt;
** problem: add_member are not passing correct assignment id in team.rb&lt;br /&gt;
&lt;br /&gt;
=== unit/assignment_team_test.rb ===&lt;br /&gt;
Because most of the tests are straightforward, only tests with concerns are listed.&lt;br /&gt;
* delete&lt;br /&gt;
** this method has bug. In the method, before sign_up.each.destory, we need to make sure sign_up is not nil. No test&lt;br /&gt;
* email&lt;br /&gt;
** this method has bug because there is no method named get_team_users. No test&lt;br /&gt;
&lt;br /&gt;
=== unit/course_team_test.rb ===&lt;br /&gt;
Only tests with concerns are listed.&lt;br /&gt;
*add_participant(course_id, user)&lt;br /&gt;
** this method should belong to course rather than course_team. This test may be not useful.&lt;br /&gt;
* self.export_all_assignment_team_related_to_course(csv, parent_id, options)&lt;br /&gt;
** this method should be deleted from course_team class. No test&lt;br /&gt;
&lt;br /&gt;
== Possible Refactoring ==&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participants_controller.rb ===&lt;br /&gt;
* These two files are never used, no tests will cover them.&lt;br /&gt;
&lt;br /&gt;
=== teams_user.rb ===&lt;br /&gt;
* In ''delete'' method, the statements about ''team.delete'' should be commented out due to the recursion it causes.&lt;br /&gt;
* ''elf.is_team_empty'' method is rewritten since the original code will cause fatal error.&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
* ''delete_select'' method will not work since the params are not in accordance with the method called inside.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84816</id>
		<title>CSC/ECE 517 Spring 2014/final doc updated qyx</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84816"/>
		<updated>2014-04-29T14:39:10Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: /* Statistics */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
=== Statistics ===&lt;br /&gt;
''Please note that the coverage generate by SimpleCov may be lower than expect due to the added fixtures.''&lt;br /&gt;
&lt;br /&gt;
; Overall (set of 6 tests) : 105 tests, 156 assertions, 2 failures, 3060 / 13457 LOC (22.74%) covered.&lt;br /&gt;
; Unit tests : 18 tests, 18 assertions, 0 failures&lt;br /&gt;
; Functional tests : 87 tests, 138 assertions, 2 failures (reasons of failure can be found in &amp;quot;Possible bugs&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
Run &lt;br /&gt;
 rake test:prepare&lt;br /&gt;
before each action.&lt;br /&gt;
To run unit tests&lt;br /&gt;
 bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/unit/team_test.rb test/unit/course_team_test.rb test/unit/assignment_team_test.rb test/unit/team_user_test.rb&lt;br /&gt;
To run functional tests&lt;br /&gt;
 bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/functional/advertise_for_partner_controller_test.rb test/functional/teams_users_controller_test.rb&lt;br /&gt;
You can also run multiple tests&lt;br /&gt;
  bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/functional/teams_users_controller_test.rb test/functional/advertise_for_partner_controller_test.rb test/unit/course_team_test.rb test/unit/assignment_team_test.rb test/unit/team_test.rb test/unit/team_user_test.rb&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
=== assignment_team.rb &amp;amp; course_team.rb ===&lt;br /&gt;
* Both assignment_team class and course_team class are inherited from team class.&lt;br /&gt;
* These two classes have similar methods, which could be used to manage teams for assignment and course more effectively.&lt;br /&gt;
== Summary of Found Issues ==&lt;br /&gt;
=== Changes made to the class===&lt;br /&gt;
==== team.rb ==== &lt;br /&gt;
''Based on the discussion from the demo, the duplicated method was deleted instead of commented out''&lt;br /&gt;
* duplicated def get_participants was removed&lt;br /&gt;
** This is removed because the same method is defined again at line 20&lt;br /&gt;
* duplicated def self.generate_team_name() was removed&lt;br /&gt;
** This is removed because the same method is defined again at line 131&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* def new was removed&lt;br /&gt;
** since it's empty, there is no need to keep the code there&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Possible Refactoring ===&lt;br /&gt;
==== team.rb ==== &lt;br /&gt;
* line 81 def self.create_node_object(name, parent_id)&lt;br /&gt;
** see the TODO at line 80, the method will not work.&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only assigning the team object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Possible Bugs ===&lt;br /&gt;
==== team.rb ====&lt;br /&gt;
* def add_member(user, assignment_id) allow nil to be passed&lt;br /&gt;
** rails always raise runtime error when nil is passed. [[#unit/team_test.rb|Test: &amp;quot;add member for course should create teams user&amp;quot; ]]&lt;br /&gt;
* def randomize_all_by_parent passing wrong arguments&lt;br /&gt;
** The code is passing wrong arguments in line 124 for add_member, there should be 2 arguments. [[#unit/team_test.rb|Test: &amp;quot;randomize_all_by_parent&amp;quot; ]]&lt;br /&gt;
* def import_team_members passing wrong arguments&lt;br /&gt;
** it is calling add_member and passing nil for assignment_id, which will make rails raise error.[[#unit/team_test.rb|Test: &amp;quot;import team members successfully&amp;quot; ]]&lt;br /&gt;
==== assignment_team.rb ====&lt;br /&gt;
* def self.get_export_fields(options)&lt;br /&gt;
** when the option team_name =&amp;gt; false, the second element of the output array should be &amp;quot;Team members&amp;quot;. But from the test, it is &amp;quot;Assignment Name&amp;quot;. This is one failure from assignment_team_test.rb&lt;br /&gt;
* def add_participant(assignment_id, user)&lt;br /&gt;
** the AssignmentParticipant.count does not increase. This is another failure from assignment_team_test.rb.&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
'''However, all of the fixtures are required to be in the fixutre folder, otherwise it will raise error.'''&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
* questions.yml&lt;br /&gt;
* signed_up_users.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Concerns for Test Cases ==&lt;br /&gt;
&lt;br /&gt;
=== functional/teams_users_controller_test.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== unit/teams_users_test.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== functional/advertise_for_partner_controller_test.rb ===&lt;br /&gt;
*  # test &amp;quot;test update advertisement fail&amp;quot; do&lt;br /&gt;
** should show flash for fail message when team.save fail, but there is no really a good way to fail team.save, so this is not implemented&lt;br /&gt;
&lt;br /&gt;
=== unit/team_test.rb ===&lt;br /&gt;
Most of test should be straightforward, so only the test with concerns will be listed below&lt;br /&gt;
*  test &amp;quot;get_participants from assignment team&amp;quot; do&lt;br /&gt;
** Please notice that this will actually call the get_participants under AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
*  test &amp;quot;generate_team_name&amp;quot; do&lt;br /&gt;
** Please notice that this method (self.generate_team_name)is modified&lt;br /&gt;
&lt;br /&gt;
*  test &amp;quot;add member for course should create teams user&amp;quot; do&lt;br /&gt;
** In the original code, it allow nil to be passed as parameter, and checks for assignment_id = nil, but rails will actually raise runtime error when nil is passed.&lt;br /&gt;
&lt;br /&gt;
*  #test &amp;quot;randomize_all_by_parent&amp;quot; do&lt;br /&gt;
** Commented out because the bug in the code make it raise error because assignment id not passed. (wrong argument)&lt;br /&gt;
&lt;br /&gt;
*  #test &amp;quot;import team members successfully&amp;quot; do&lt;br /&gt;
** problem: add_member are not passing correct assignment id in team.rb&lt;br /&gt;
&lt;br /&gt;
=== unit/assignment_team_test.rb ===&lt;br /&gt;
Because most of the tests are straightforward, only tests with concerns are listed.&lt;br /&gt;
* delete&lt;br /&gt;
** this method has bug. In the method, before sign_up.each.destory, we need to make sure sign_up is not nil. No test&lt;br /&gt;
* email&lt;br /&gt;
** this method has bug because there is no method named get_team_users. No test&lt;br /&gt;
&lt;br /&gt;
=== unit/course_team_test.rb ===&lt;br /&gt;
Only tests with concerns are listed.&lt;br /&gt;
*add_participant(course_id, user)&lt;br /&gt;
** this method should belong to course rather than course_team. This test may be not useful.&lt;br /&gt;
* self.export_all_assignment_team_related_to_course(csv, parent_id, options)&lt;br /&gt;
** this method should be deleted from course_team class. No test&lt;br /&gt;
&lt;br /&gt;
== Possible Refactoring ==&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participants_controller.rb ===&lt;br /&gt;
* These two files are never used, no tests will cover them.&lt;br /&gt;
&lt;br /&gt;
=== teams_user.rb ===&lt;br /&gt;
* In ''delete'' method, the statements about ''team.delete'' should be commented out due to the recursion it causes.&lt;br /&gt;
* ''elf.is_team_empty'' method is rewritten since the original code will cause fatal error.&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
* ''delete_select'' method will not work since the params are not in accordance with the method called inside.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84815</id>
		<title>CSC/ECE 517 Spring 2014/final doc updated qyx</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84815"/>
		<updated>2014-04-29T14:37:45Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: /* Possible Bugs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
=== Statistics ===&lt;br /&gt;
''Please note that the coverage generate by SimpleCov may be lower than expect due to the added fixtures.''&lt;br /&gt;
&lt;br /&gt;
; Overall (set of 6 tests) : 105 tests, 156 assertions, 2 failures, 3060 / 13457 LOC (22.74%) covered.&lt;br /&gt;
; Unit tests : 18 tests, 18 assertions, 0 failures&lt;br /&gt;
; Functional tests : 87 tests, 138 assertions, 2 failures&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
Run &lt;br /&gt;
 rake test:prepare&lt;br /&gt;
before each action.&lt;br /&gt;
To run unit tests&lt;br /&gt;
 bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/unit/team_test.rb test/unit/course_team_test.rb test/unit/assignment_team_test.rb test/unit/team_user_test.rb&lt;br /&gt;
To run functional tests&lt;br /&gt;
 bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/functional/advertise_for_partner_controller_test.rb test/functional/teams_users_controller_test.rb&lt;br /&gt;
You can also run multiple tests&lt;br /&gt;
  bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/functional/teams_users_controller_test.rb test/functional/advertise_for_partner_controller_test.rb test/unit/course_team_test.rb test/unit/assignment_team_test.rb test/unit/team_test.rb test/unit/team_user_test.rb&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
=== assignment_team.rb &amp;amp; course_team.rb ===&lt;br /&gt;
* Both assignment_team class and course_team class are inherited from team class.&lt;br /&gt;
* These two classes have similar methods, which could be used to manage teams for assignment and course more effectively.&lt;br /&gt;
== Summary of Found Issues ==&lt;br /&gt;
=== Changes made to the class===&lt;br /&gt;
==== team.rb ==== &lt;br /&gt;
''Based on the discussion from the demo, the duplicated method was deleted instead of commented out''&lt;br /&gt;
* duplicated def get_participants was removed&lt;br /&gt;
** This is removed because the same method is defined again at line 20&lt;br /&gt;
* duplicated def self.generate_team_name() was removed&lt;br /&gt;
** This is removed because the same method is defined again at line 131&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* def new was removed&lt;br /&gt;
** since it's empty, there is no need to keep the code there&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Possible Refactoring ===&lt;br /&gt;
==== team.rb ==== &lt;br /&gt;
* line 81 def self.create_node_object(name, parent_id)&lt;br /&gt;
** see the TODO at line 80, the method will not work.&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only assigning the team object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Possible Bugs ===&lt;br /&gt;
==== team.rb ====&lt;br /&gt;
* def add_member(user, assignment_id) allow nil to be passed&lt;br /&gt;
** rails always raise runtime error when nil is passed. [[#unit/team_test.rb|Test: &amp;quot;add member for course should create teams user&amp;quot; ]]&lt;br /&gt;
* def randomize_all_by_parent passing wrong arguments&lt;br /&gt;
** The code is passing wrong arguments in line 124 for add_member, there should be 2 arguments. [[#unit/team_test.rb|Test: &amp;quot;randomize_all_by_parent&amp;quot; ]]&lt;br /&gt;
* def import_team_members passing wrong arguments&lt;br /&gt;
** it is calling add_member and passing nil for assignment_id, which will make rails raise error.[[#unit/team_test.rb|Test: &amp;quot;import team members successfully&amp;quot; ]]&lt;br /&gt;
==== assignment_team.rb ====&lt;br /&gt;
* def self.get_export_fields(options)&lt;br /&gt;
** when the option team_name =&amp;gt; false, the second element of the output array should be &amp;quot;Team members&amp;quot;. But from the test, it is &amp;quot;Assignment Name&amp;quot;. This is one failure from assignment_team_test.rb&lt;br /&gt;
* def add_participant(assignment_id, user)&lt;br /&gt;
** the AssignmentParticipant.count does not increase. This is another failure from assignment_team_test.rb.&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
'''However, all of the fixtures are required to be in the fixutre folder, otherwise it will raise error.'''&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
* questions.yml&lt;br /&gt;
* signed_up_users.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Concerns for Test Cases ==&lt;br /&gt;
&lt;br /&gt;
=== functional/teams_users_controller_test.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== unit/teams_users_test.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== functional/advertise_for_partner_controller_test.rb ===&lt;br /&gt;
*  # test &amp;quot;test update advertisement fail&amp;quot; do&lt;br /&gt;
** should show flash for fail message when team.save fail, but there is no really a good way to fail team.save, so this is not implemented&lt;br /&gt;
&lt;br /&gt;
=== unit/team_test.rb ===&lt;br /&gt;
Most of test should be straightforward, so only the test with concerns will be listed below&lt;br /&gt;
*  test &amp;quot;get_participants from assignment team&amp;quot; do&lt;br /&gt;
** Please notice that this will actually call the get_participants under AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
*  test &amp;quot;generate_team_name&amp;quot; do&lt;br /&gt;
** Please notice that this method (self.generate_team_name)is modified&lt;br /&gt;
&lt;br /&gt;
*  test &amp;quot;add member for course should create teams user&amp;quot; do&lt;br /&gt;
** In the original code, it allow nil to be passed as parameter, and checks for assignment_id = nil, but rails will actually raise runtime error when nil is passed.&lt;br /&gt;
&lt;br /&gt;
*  #test &amp;quot;randomize_all_by_parent&amp;quot; do&lt;br /&gt;
** Commented out because the bug in the code make it raise error because assignment id not passed. (wrong argument)&lt;br /&gt;
&lt;br /&gt;
*  #test &amp;quot;import team members successfully&amp;quot; do&lt;br /&gt;
** problem: add_member are not passing correct assignment id in team.rb&lt;br /&gt;
&lt;br /&gt;
=== unit/assignment_team_test.rb ===&lt;br /&gt;
Because most of the tests are straightforward, only tests with concerns are listed.&lt;br /&gt;
* delete&lt;br /&gt;
** this method has bug. In the method, before sign_up.each.destory, we need to make sure sign_up is not nil. No test&lt;br /&gt;
* email&lt;br /&gt;
** this method has bug because there is no method named get_team_users. No test&lt;br /&gt;
&lt;br /&gt;
=== unit/course_team_test.rb ===&lt;br /&gt;
Only tests with concerns are listed.&lt;br /&gt;
*add_participant(course_id, user)&lt;br /&gt;
** this method should belong to course rather than course_team. This test may be not useful.&lt;br /&gt;
* self.export_all_assignment_team_related_to_course(csv, parent_id, options)&lt;br /&gt;
** this method should be deleted from course_team class. No test&lt;br /&gt;
&lt;br /&gt;
== Possible Refactoring ==&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participants_controller.rb ===&lt;br /&gt;
* These two files are never used, no tests will cover them.&lt;br /&gt;
&lt;br /&gt;
=== teams_user.rb ===&lt;br /&gt;
* In ''delete'' method, the statements about ''team.delete'' should be commented out due to the recursion it causes.&lt;br /&gt;
* ''elf.is_team_empty'' method is rewritten since the original code will cause fatal error.&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
* ''delete_select'' method will not work since the params are not in accordance with the method called inside.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84812</id>
		<title>CSC/ECE 517 Spring 2014/final doc updated qyx</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84812"/>
		<updated>2014-04-29T14:26:52Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: /* unit/course_team_test.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
=== Statistics ===&lt;br /&gt;
''Please note that the coverage generate by SimpleCov may be lower than expect due to the added fixtures.''&lt;br /&gt;
&lt;br /&gt;
; Overall (set of 6 tests) : 105 tests, 156 assertions, 2 failures, 3060 / 13457 LOC (22.74%) covered.&lt;br /&gt;
; Unit tests : 18 tests, 18 assertions, 0 failures&lt;br /&gt;
; Functional tests : 87 tests, 138 assertions, 2 failures&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
Run &lt;br /&gt;
 rake test:prepare&lt;br /&gt;
before each action.&lt;br /&gt;
To run unit tests&lt;br /&gt;
 bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/unit/team_test.rb test/unit/course_team_test.rb test/unit/assignment_team_test.rb test/unit/team_user_test.rb&lt;br /&gt;
To run functional tests&lt;br /&gt;
 bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/functional/advertise_for_partner_controller_test.rb test/functional/teams_users_controller_test.rb&lt;br /&gt;
You can also run multiple tests&lt;br /&gt;
  bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/functional/teams_users_controller_test.rb test/functional/advertise_for_partner_controller_test.rb test/unit/course_team_test.rb test/unit/assignment_team_test.rb test/unit/team_test.rb test/unit/team_user_test.rb&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
=== assignment_team.rb &amp;amp; course_team.rb ===&lt;br /&gt;
* Both assignment_team class and course_team class are inherited from team class.&lt;br /&gt;
* These two classes have similar methods, which could be used to manage teams for assignment and course more effectively.&lt;br /&gt;
== Summary of Found Issues ==&lt;br /&gt;
=== Changes made to the class===&lt;br /&gt;
==== team.rb ==== &lt;br /&gt;
''Based on the discussion from the demo, the duplicated method was deleted instead of commented out''&lt;br /&gt;
* duplicated def get_participants was removed&lt;br /&gt;
** This is removed because the same method is defined again at line 20&lt;br /&gt;
* duplicated def self.generate_team_name() was removed&lt;br /&gt;
** This is removed because the same method is defined again at line 131&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* def new was removed&lt;br /&gt;
** since it's empty, there is no need to keep the code there&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Possible Refactoring ===&lt;br /&gt;
==== team.rb ==== &lt;br /&gt;
* line 81 def self.create_node_object(name, parent_id)&lt;br /&gt;
** see the TODO at line 80, the method will not work.&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only assigning the team object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Possible Bugs ===&lt;br /&gt;
==== team.rb ====&lt;br /&gt;
* def add_member(user, assignment_id) allow nil to be passed&lt;br /&gt;
** rails always raise runtime error when nil is passed. [[#unit/team_test.rb|Test: &amp;quot;add member for course should create teams user&amp;quot; ]]&lt;br /&gt;
* def randomize_all_by_parent passing wrong arguments&lt;br /&gt;
** The code is passing wrong arguments in line 124 for add_member, there should be 2 arguments. [[#unit/team_test.rb|Test: &amp;quot;randomize_all_by_parent&amp;quot; ]]&lt;br /&gt;
* def import_team_members passing wrong arguments&lt;br /&gt;
** it is calling add_member and passing nil for assignment_id, which will make rails raise error.[[#unit/team_test.rb|Test: &amp;quot;import team members successfully&amp;quot; ]]&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
'''However, all of the fixtures are required to be in the fixutre folder, otherwise it will raise error.'''&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
* questions.yml&lt;br /&gt;
* signed_up_users.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Concerns for Test Cases ==&lt;br /&gt;
&lt;br /&gt;
=== functional/teams_users_controller_test.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== unit/teams_users_test.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== functional/advertise_for_partner_controller_test.rb ===&lt;br /&gt;
*  # test &amp;quot;test update advertisement fail&amp;quot; do&lt;br /&gt;
** should show flash for fail message when team.save fail, but there is no really a good way to fail team.save, so this is not implemented&lt;br /&gt;
&lt;br /&gt;
=== unit/team_test.rb ===&lt;br /&gt;
Most of test should be straightforward, so only the test with concerns will be listed below&lt;br /&gt;
*  test &amp;quot;get_participants from assignment team&amp;quot; do&lt;br /&gt;
** Please notice that this will actually call the get_participants under AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
*  test &amp;quot;generate_team_name&amp;quot; do&lt;br /&gt;
** Please notice that this method (self.generate_team_name)is modified&lt;br /&gt;
&lt;br /&gt;
*  test &amp;quot;add member for course should create teams user&amp;quot; do&lt;br /&gt;
** In the original code, it allow nil to be passed as parameter, and checks for assignment_id = nil, but rails will actually raise runtime error when nil is passed.&lt;br /&gt;
&lt;br /&gt;
*  #test &amp;quot;randomize_all_by_parent&amp;quot; do&lt;br /&gt;
** Commented out because the bug in the code make it raise error because assignment id not passed. (wrong argument)&lt;br /&gt;
&lt;br /&gt;
*  #test &amp;quot;import team members successfully&amp;quot; do&lt;br /&gt;
** problem: add_member are not passing correct assignment id in team.rb&lt;br /&gt;
&lt;br /&gt;
=== unit/assignment_team_test.rb ===&lt;br /&gt;
Because most of the tests are straightforward, only tests with concerns are listed.&lt;br /&gt;
* delete&lt;br /&gt;
** this method has bug. In the method, before sign_up.each.destory, we need to make sure sign_up is not nil. No test&lt;br /&gt;
* email&lt;br /&gt;
** this method has bug because there is no method named get_team_users. No test&lt;br /&gt;
&lt;br /&gt;
=== unit/course_team_test.rb ===&lt;br /&gt;
Only tests with concerns are listed.&lt;br /&gt;
*add_participant(course_id, user)&lt;br /&gt;
** this method should belong to course rather than course_team. This test may be not useful.&lt;br /&gt;
* self.export_all_assignment_team_related_to_course(csv, parent_id, options)&lt;br /&gt;
** this method should be deleted from course_team class. No test&lt;br /&gt;
&lt;br /&gt;
== Possible Refactoring ==&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participants_controller.rb ===&lt;br /&gt;
* These two files are never used, no tests will cover them.&lt;br /&gt;
&lt;br /&gt;
=== teams_user.rb ===&lt;br /&gt;
* In ''delete'' method, the statements about ''team.delete'' should be commented out due to the recursion it causes.&lt;br /&gt;
* ''elf.is_team_empty'' method is rewritten since the original code will cause fatal error.&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
* ''delete_select'' method will not work since the params are not in accordance with the method called inside.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84810</id>
		<title>CSC/ECE 517 Spring 2014/final doc updated qyx</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84810"/>
		<updated>2014-04-29T14:22:34Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: /* unit/assignment_team_test.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
=== Statistics ===&lt;br /&gt;
''Please note that the coverage generate by SimpleCov may be lower than expect due to the added fixtures.''&lt;br /&gt;
&lt;br /&gt;
; Overall (set of 6 tests) : 105 tests, 156 assertions, 2 failures, 3060 / 13457 LOC (22.74%) covered.&lt;br /&gt;
; Unit tests : 18 tests, 18 assertions, 0 failures&lt;br /&gt;
; Functional tests : 87 tests, 138 assertions, 2 failures&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
Run &lt;br /&gt;
 rake test:prepare&lt;br /&gt;
before each action.&lt;br /&gt;
To run unit tests&lt;br /&gt;
 bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/unit/team_test.rb test/unit/course_team_test.rb test/unit/assignment_team_test.rb test/unit/team_user_test.rb&lt;br /&gt;
To run functional tests&lt;br /&gt;
 bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/functional/advertise_for_partner_controller_test.rb test/functional/teams_users_controller_test.rb&lt;br /&gt;
You can also run multiple tests&lt;br /&gt;
  bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/functional/teams_users_controller_test.rb test/functional/advertise_for_partner_controller_test.rb test/unit/course_team_test.rb test/unit/assignment_team_test.rb test/unit/team_test.rb test/unit/team_user_test.rb&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
=== assignment_team.rb &amp;amp; course_team.rb ===&lt;br /&gt;
* Both assignment_team class and course_team class are inherited from team class.&lt;br /&gt;
* These two classes have similar methods, which could be used to manage teams for assignment and course more effectively.&lt;br /&gt;
== Summary of Found Issues ==&lt;br /&gt;
=== Changes made to the class===&lt;br /&gt;
==== team.rb ==== &lt;br /&gt;
''Based on the discussion from the demo, the duplicated method was deleted instead of commented out''&lt;br /&gt;
* duplicated def get_participants was removed&lt;br /&gt;
** This is removed because the same method is defined again at line 20&lt;br /&gt;
* duplicated def self.generate_team_name() was removed&lt;br /&gt;
** This is removed because the same method is defined again at line 131&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* def new was removed&lt;br /&gt;
** since it's empty, there is no need to keep the code there&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Possible Refactoring ===&lt;br /&gt;
==== team.rb ==== &lt;br /&gt;
* line 81 def self.create_node_object(name, parent_id)&lt;br /&gt;
** see the TODO at line 80, the method will not work.&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only assigning the team object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Possible Bugs ===&lt;br /&gt;
==== team.rb ====&lt;br /&gt;
* def add_member(user, assignment_id) allow nil to be passed&lt;br /&gt;
** rails always raise runtime error when nil is passed. [[#unit/team_test.rb|Test: &amp;quot;add member for course should create teams user&amp;quot; ]]&lt;br /&gt;
* def randomize_all_by_parent passing wrong arguments&lt;br /&gt;
** The code is passing wrong arguments in line 124 for add_member, there should be 2 arguments. [[#unit/team_test.rb|Test: &amp;quot;randomize_all_by_parent&amp;quot; ]]&lt;br /&gt;
* def import_team_members passing wrong arguments&lt;br /&gt;
** it is calling add_member and passing nil for assignment_id, which will make rails raise error.[[#unit/team_test.rb|Test: &amp;quot;import team members successfully&amp;quot; ]]&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
'''However, all of the fixtures are required to be in the fixutre folder, otherwise it will raise error.'''&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
* questions.yml&lt;br /&gt;
* signed_up_users.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Concerns for Test Cases ==&lt;br /&gt;
&lt;br /&gt;
=== functional/teams_users_controller_test.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== unit/teams_users_test.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== functional/advertise_for_partner_controller_test.rb ===&lt;br /&gt;
*  # test &amp;quot;test update advertisement fail&amp;quot; do&lt;br /&gt;
** should show flash for fail message when team.save fail, but there is no really a good way to fail team.save, so this is not implemented&lt;br /&gt;
&lt;br /&gt;
=== unit/team_test.rb ===&lt;br /&gt;
Most of test should be straightforward, so only the test with concerns will be listed below&lt;br /&gt;
*  test &amp;quot;get_participants from assignment team&amp;quot; do&lt;br /&gt;
** Please notice that this will actually call the get_participants under AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
*  test &amp;quot;generate_team_name&amp;quot; do&lt;br /&gt;
** Please notice that this method (self.generate_team_name)is modified&lt;br /&gt;
&lt;br /&gt;
*  test &amp;quot;add member for course should create teams user&amp;quot; do&lt;br /&gt;
** In the original code, it allow nil to be passed as parameter, and checks for assignment_id = nil, but rails will actually raise runtime error when nil is passed.&lt;br /&gt;
&lt;br /&gt;
*  #test &amp;quot;randomize_all_by_parent&amp;quot; do&lt;br /&gt;
** Commented out because the bug in the code make it raise error because assignment id not passed. (wrong argument)&lt;br /&gt;
&lt;br /&gt;
*  #test &amp;quot;import team members successfully&amp;quot; do&lt;br /&gt;
** problem: add_member are not passing correct assignment id in team.rb&lt;br /&gt;
&lt;br /&gt;
=== unit/assignment_team_test.rb ===&lt;br /&gt;
Because most of the tests are straightforward, only tests with concerns are listed.&lt;br /&gt;
* delete&lt;br /&gt;
** this method has bug. In the method, before sign_up.each.destory, we need to make sure sign_up is not nil. No test&lt;br /&gt;
* email&lt;br /&gt;
** this method has bug because there is no method named get_team_users. No test&lt;br /&gt;
&lt;br /&gt;
=== unit/course_team_test.rb ===&lt;br /&gt;
Because most of the methods in course_team.rb are similar with that in assignment_team.rb if they have the same name. So I skip the same name method. Take the test/unit/course_team_test.rb as a reference.&lt;br /&gt;
* self.export_all_assignment_team_related_to_course(csv, parent_id, options)&lt;br /&gt;
** this method should be deleted here. No test&lt;br /&gt;
&lt;br /&gt;
== Possible Refactoring ==&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participants_controller.rb ===&lt;br /&gt;
* These two files are never used, no tests will cover them.&lt;br /&gt;
&lt;br /&gt;
=== teams_user.rb ===&lt;br /&gt;
* In ''delete'' method, the statements about ''team.delete'' should be commented out due to the recursion it causes.&lt;br /&gt;
* ''elf.is_team_empty'' method is rewritten since the original code will cause fatal error.&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
* ''delete_select'' method will not work since the params are not in accordance with the method called inside.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84807</id>
		<title>CSC/ECE 517 Spring 2014/final doc updated qyx</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84807"/>
		<updated>2014-04-29T14:15:38Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: /* unit/assignment_team_test.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
=== Statistics ===&lt;br /&gt;
''Please note that the coverage generate by SimpleCov may be lower than expect due to the added fixtures.''&lt;br /&gt;
&lt;br /&gt;
; Overall (set of 6 tests) : 105 tests, 156 assertions, 2 failures, 3060 / 13457 LOC (22.74%) covered.&lt;br /&gt;
; Unit tests : 18 tests, 18 assertions, 0 failures&lt;br /&gt;
; Functional tests : 87 tests, 138 assertions, 2 failures&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
Run &lt;br /&gt;
 rake test:prepare&lt;br /&gt;
before each action.&lt;br /&gt;
To run unit tests&lt;br /&gt;
 bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/unit/team_test.rb test/unit/course_team_test.rb test/unit/assignment_team_test.rb test/unit/team_user_test.rb&lt;br /&gt;
To run functional tests&lt;br /&gt;
 bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/functional/advertise_for_partner_controller_test.rb test/functional/teams_users_controller_test.rb&lt;br /&gt;
You can also run multiple tests&lt;br /&gt;
  bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/functional/teams_users_controller_test.rb test/functional/advertise_for_partner_controller_test.rb test/unit/course_team_test.rb test/unit/assignment_team_test.rb test/unit/team_test.rb test/unit/team_user_test.rb&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
=== assignment_team.rb &amp;amp; course_team.rb ===&lt;br /&gt;
* Both assignment_team class and course_team class are inherited from team class.&lt;br /&gt;
* These two classes have similar methods, which could be used to manage teams for assignment and course more effectively.&lt;br /&gt;
== Summary of Found Issues ==&lt;br /&gt;
=== Changes made to the class===&lt;br /&gt;
==== team.rb ==== &lt;br /&gt;
''Based on the discussion from the demo, the duplicated method was deleted instead of commented out''&lt;br /&gt;
* duplicated def get_participants was removed&lt;br /&gt;
** This is removed because the same method is defined again at line 20&lt;br /&gt;
* duplicated def self.generate_team_name() was removed&lt;br /&gt;
** This is removed because the same method is defined again at line 131&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* def new was removed&lt;br /&gt;
** since it's empty, there is no need to keep the code there&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Possible Refactoring ===&lt;br /&gt;
==== team.rb ==== &lt;br /&gt;
* line 81 def self.create_node_object(name, parent_id)&lt;br /&gt;
** see the TODO at line 80, the method will not work.&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only assigning the team object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Possible Bugs ===&lt;br /&gt;
==== team.rb ====&lt;br /&gt;
* def add_member(user, assignment_id) allow nil to be passed&lt;br /&gt;
** rails always raise runtime error when nil is passed. [[#unit/team_test.rb|Test: &amp;quot;add member for course should create teams user&amp;quot; ]]&lt;br /&gt;
* def randomize_all_by_parent passing wrong arguments&lt;br /&gt;
** The code is passing wrong arguments in line 124 for add_member, there should be 2 arguments. [[#unit/team_test.rb|Test: &amp;quot;randomize_all_by_parent&amp;quot; ]]&lt;br /&gt;
* def import_team_members passing wrong arguments&lt;br /&gt;
** it is calling add_member and passing nil for assignment_id, which will make rails raise error.[[#unit/team_test.rb|Test: &amp;quot;import team members successfully&amp;quot; ]]&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
'''However, all of the fixtures are required to be in the fixutre folder, otherwise it will raise error.'''&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
* questions.yml&lt;br /&gt;
* signed_up_users.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Concerns for Test Cases ==&lt;br /&gt;
&lt;br /&gt;
=== functional/teams_users_controller_test.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== unit/teams_users_test.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== functional/advertise_for_partner_controller_test.rb ===&lt;br /&gt;
*  # test &amp;quot;test update advertisement fail&amp;quot; do&lt;br /&gt;
** should show flash for fail message when team.save fail, but there is no really a good way to fail team.save, so this is not implemented&lt;br /&gt;
&lt;br /&gt;
=== unit/team_test.rb ===&lt;br /&gt;
Most of test should be straightforward, so only the test with concerns will be listed below&lt;br /&gt;
*  test &amp;quot;get_participants from assignment team&amp;quot; do&lt;br /&gt;
** Please notice that this will actually call the get_participants under AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
*  test &amp;quot;generate_team_name&amp;quot; do&lt;br /&gt;
** Please notice that this method (self.generate_team_name)is modified&lt;br /&gt;
&lt;br /&gt;
*  test &amp;quot;add member for course should create teams user&amp;quot; do&lt;br /&gt;
** In the original code, it allow nil to be passed as parameter, and checks for assignment_id = nil, but rails will actually raise runtime error when nil is passed.&lt;br /&gt;
&lt;br /&gt;
*  #test &amp;quot;randomize_all_by_parent&amp;quot; do&lt;br /&gt;
** Commented out because the bug in the code make it raise error because assignment id not passed. (wrong argument)&lt;br /&gt;
&lt;br /&gt;
*  #test &amp;quot;import team members successfully&amp;quot; do&lt;br /&gt;
** problem: add_member are not passing correct assignment id in team.rb&lt;br /&gt;
&lt;br /&gt;
=== unit/assignment_team_test.rb ===&lt;br /&gt;
* reviewed_by?(reviewer)&lt;br /&gt;
** TeamReviewResponseMap is empty, so test this method will return false&lt;br /&gt;
* reviewed_contributor?(contributor)&lt;br /&gt;
** TeamReviewResponseMap is empty, so test this method will return false&lt;br /&gt;
* delete&lt;br /&gt;
** this method has bug. No test&lt;br /&gt;
* email&lt;br /&gt;
** this method has bug because there is no method named get_team_users. No test&lt;br /&gt;
&lt;br /&gt;
=== unit/course_team_test.rb ===&lt;br /&gt;
Because most of the methods in course_team.rb are similar with that in assignment_team.rb if they have the same name. So I skip the same name method. Take the test/unit/course_team_test.rb as a reference.&lt;br /&gt;
* self.export_all_assignment_team_related_to_course(csv, parent_id, options)&lt;br /&gt;
** this method should be deleted here. No test&lt;br /&gt;
&lt;br /&gt;
== Possible Refactoring ==&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participants_controller.rb ===&lt;br /&gt;
* These two files are never used, no tests will cover them.&lt;br /&gt;
&lt;br /&gt;
=== teams_user.rb ===&lt;br /&gt;
* In ''delete'' method, the statements about ''team.delete'' should be commented out due to the recursion it causes.&lt;br /&gt;
* ''elf.is_team_empty'' method is rewritten since the original code will cause fatal error.&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
* ''delete_select'' method will not work since the params are not in accordance with the method called inside.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84806</id>
		<title>CSC/ECE 517 Spring 2014/final doc updated qyx</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84806"/>
		<updated>2014-04-29T14:13:17Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: /* unit/assignment_team_test.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
=== Statistics ===&lt;br /&gt;
''Please note that the coverage generate by SimpleCov may be lower than expect due to the added fixtures.''&lt;br /&gt;
&lt;br /&gt;
; Overall (set of 6 tests) : 105 tests, 156 assertions, 2 failures, 3060 / 13457 LOC (22.74%) covered.&lt;br /&gt;
; Unit tests : 18 tests, 18 assertions, 0 failures&lt;br /&gt;
; Functional tests : 87 tests, 138 assertions, 2 failures&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
Run &lt;br /&gt;
 rake test:prepare&lt;br /&gt;
before each action.&lt;br /&gt;
To run unit tests&lt;br /&gt;
 bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/unit/team_test.rb test/unit/course_team_test.rb test/unit/assignment_team_test.rb test/unit/team_user_test.rb&lt;br /&gt;
To run functional tests&lt;br /&gt;
 bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/functional/advertise_for_partner_controller_test.rb test/functional/teams_users_controller_test.rb&lt;br /&gt;
You can also run multiple tests&lt;br /&gt;
  bundle exec ruby -I.:test -e &amp;quot;ARGV.each{|f| require f}&amp;quot; test/functional/teams_users_controller_test.rb test/functional/advertise_for_partner_controller_test.rb test/unit/course_team_test.rb test/unit/assignment_team_test.rb test/unit/team_test.rb test/unit/team_user_test.rb&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
=== assignment_team.rb &amp;amp; course_team.rb ===&lt;br /&gt;
* Both assignment_team class and course_team class are inherited from team class.&lt;br /&gt;
* These two classes have similar methods, which could be used to manage teams for assignment and course more effectively.&lt;br /&gt;
== Summary of Found Issues ==&lt;br /&gt;
=== Changes made to the class===&lt;br /&gt;
==== team.rb ==== &lt;br /&gt;
''Based on the discussion from the demo, the duplicated method was deleted instead of commented out''&lt;br /&gt;
* duplicated def get_participants was removed&lt;br /&gt;
** This is removed because the same method is defined again at line 20&lt;br /&gt;
* duplicated def self.generate_team_name() was removed&lt;br /&gt;
** This is removed because the same method is defined again at line 131&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* def new was removed&lt;br /&gt;
** since it's empty, there is no need to keep the code there&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Possible Refactoring ===&lt;br /&gt;
==== team.rb ==== &lt;br /&gt;
* line 81 def self.create_node_object(name, parent_id)&lt;br /&gt;
** see the TODO at line 80, the method will not work.&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only assigning the team object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Possible Bugs ===&lt;br /&gt;
==== team.rb ====&lt;br /&gt;
* def add_member(user, assignment_id) allow nil to be passed&lt;br /&gt;
** rails always raise runtime error when nil is passed. [[#unit/team_test.rb|Test: &amp;quot;add member for course should create teams user&amp;quot; ]]&lt;br /&gt;
* def randomize_all_by_parent passing wrong arguments&lt;br /&gt;
** The code is passing wrong arguments in line 124 for add_member, there should be 2 arguments. [[#unit/team_test.rb|Test: &amp;quot;randomize_all_by_parent&amp;quot; ]]&lt;br /&gt;
* def import_team_members passing wrong arguments&lt;br /&gt;
** it is calling add_member and passing nil for assignment_id, which will make rails raise error.[[#unit/team_test.rb|Test: &amp;quot;import team members successfully&amp;quot; ]]&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
'''However, all of the fixtures are required to be in the fixutre folder, otherwise it will raise error.'''&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
* questions.yml&lt;br /&gt;
* signed_up_users.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Concerns for Test Cases ==&lt;br /&gt;
&lt;br /&gt;
=== functional/teams_users_controller_test.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== unit/teams_users_test.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== functional/advertise_for_partner_controller_test.rb ===&lt;br /&gt;
*  # test &amp;quot;test update advertisement fail&amp;quot; do&lt;br /&gt;
** should show flash for fail message when team.save fail, but there is no really a good way to fail team.save, so this is not implemented&lt;br /&gt;
&lt;br /&gt;
=== unit/team_test.rb ===&lt;br /&gt;
Most of test should be straightforward, so only the test with concerns will be listed below&lt;br /&gt;
*  test &amp;quot;get_participants from assignment team&amp;quot; do&lt;br /&gt;
** Please notice that this will actually call the get_participants under AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
*  test &amp;quot;generate_team_name&amp;quot; do&lt;br /&gt;
** Please notice that this method (self.generate_team_name)is modified&lt;br /&gt;
&lt;br /&gt;
*  test &amp;quot;add member for course should create teams user&amp;quot; do&lt;br /&gt;
** In the original code, it allow nil to be passed as parameter, and checks for assignment_id = nil, but rails will actually raise runtime error when nil is passed.&lt;br /&gt;
&lt;br /&gt;
*  #test &amp;quot;randomize_all_by_parent&amp;quot; do&lt;br /&gt;
** Commented out because the bug in the code make it raise error because assignment id not passed. (wrong argument)&lt;br /&gt;
&lt;br /&gt;
*  #test &amp;quot;import team members successfully&amp;quot; do&lt;br /&gt;
** problem: add_member are not passing correct assignment id in team.rb&lt;br /&gt;
&lt;br /&gt;
=== unit/assignment_team_test.rb ===&lt;br /&gt;
* assign_reviewer(reviewer)&lt;br /&gt;
** assign a reviewer for this assignment team, and TeamReviewResponseMap.count increases&lt;br /&gt;
* reviewed_by?(reviewer)&lt;br /&gt;
** TeamReviewResponseMap is empty, so test this method will return false&lt;br /&gt;
* reviewed_contributor?(contributor)&lt;br /&gt;
** TeamReviewResponseMap is empty, so test this method will return false&lt;br /&gt;
* delete&lt;br /&gt;
** this method has bug. No test&lt;br /&gt;
* get_submitted_files&lt;br /&gt;
** submitted_file must be empty, expect nil&lt;br /&gt;
* self.handle_duplicate(team, name, assignment_id, handle_duplicates)&lt;br /&gt;
** test in different cases(team is nil, option is &amp;quot;ignore&amp;quot;, option is &amp;quot;rename&amp;quot;)&lt;br /&gt;
* self.import(row,session,assignment_id,options)&lt;br /&gt;
** test in different cases(argument error, has_column_name is true, has_column_name is false)&lt;br /&gt;
* email&lt;br /&gt;
** this method has bug because there is no method named get_team_users. No test&lt;br /&gt;
* copy(course_id)&lt;br /&gt;
** TeamUserNode.count and TeamsUser.count increase&lt;br /&gt;
* add_participant(assignment_id, user)&lt;br /&gt;
** AssignmentParticipant.count increases&lt;br /&gt;
* assignment&lt;br /&gt;
** return value should equal what we expect&lt;br /&gt;
* get_scores(questions)&lt;br /&gt;
** return output's total score is not nil and the assignment team is what we expect&lt;br /&gt;
* self.get_team(participant)&lt;br /&gt;
** return team is what we expect&lt;br /&gt;
* self.export(csv, parent_id, options)&lt;br /&gt;
** test in different cases(team_name is true, team_name is false)&lt;br /&gt;
* self.get_export_fields(options)&lt;br /&gt;
** test if the fields' name is right&lt;br /&gt;
* self.create_team_and_node(assignment_id)&lt;br /&gt;
** assignent team and team node are not nil&lt;br /&gt;
* self.remove_team_by_id(id)&lt;br /&gt;
** check the removed team cannot be found in AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
=== unit/course_team_test.rb ===&lt;br /&gt;
Because most of the methods in course_team.rb are similar with that in assignment_team.rb if they have the same name. So I skip the same name method. Take the test/unit/course_team_test.rb as a reference.&lt;br /&gt;
* self.export_all_assignment_team_related_to_course(csv, parent_id, options)&lt;br /&gt;
** this method should be deleted here. No test&lt;br /&gt;
&lt;br /&gt;
== Possible Refactoring ==&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participants_controller.rb ===&lt;br /&gt;
* These two files are never used, no tests will cover them.&lt;br /&gt;
&lt;br /&gt;
=== teams_user.rb ===&lt;br /&gt;
* In ''delete'' method, the statements about ''team.delete'' should be commented out due to the recursion it causes.&lt;br /&gt;
* ''elf.is_team_empty'' method is rewritten since the original code will cause fatal error.&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
* ''delete_select'' method will not work since the params are not in accordance with the method called inside.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84726</id>
		<title>CSC/ECE 517 Spring 2014/final doc updated qyx</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84726"/>
		<updated>2014-04-24T20:26:03Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: /* assignment_team.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
=== assignment_team.rb &amp;amp; course_team.rb ===&lt;br /&gt;
* Both assignment_team class and course_team class are inherited from team class.&lt;br /&gt;
* These two classes have similar methods, which could be used to manage teams for assignment and course more effectively.&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
The “team” object represents a team that consists students who are either participants of course or assignment.&lt;br /&gt;
a team will response to the request on: &lt;br /&gt;
&lt;br /&gt;
* get_participants : get participant in the team&lt;br /&gt;
* delete : delete a team member in the team&lt;br /&gt;
* get_node_type : will return “TeamNode”&lt;br /&gt;
* get_author_name : will return team’s name&lt;br /&gt;
* generate_team_name() : serialize the automatically generated team name (e.g. team 1, team 2, etc.)&lt;br /&gt;
* get_possible_team_members(name) : find a team member by name&lt;br /&gt;
* has_user(user : find a team member by user object&lt;br /&gt;
* add_member(user, assignment_id) : add a user to an assignment team&lt;br /&gt;
* copy_members(new_team) : copy current member in the team to the new team&lt;br /&gt;
* create_node_object(name, parent_id) : ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
* check_for_exisiting(parent, name, team_type) : check if the team name under the same assignment or course is in use.&lt;br /&gt;
* delete_all_by_parent(parent) : delete all teams under the same course/assignment&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size) : randomly assign team members&lt;br /&gt;
* generate_team_name(teamnameprefix) : generate team name with prefix (e.g. prefix_Team1) &lt;br /&gt;
* import_team_members(starting_index, row) : import user from specific index of users and length&lt;br /&gt;
&lt;br /&gt;
=== app/unit/assignment_team.rb ===&lt;br /&gt;
* includes?(participant): check if this assignment team include this participant&lt;br /&gt;
* assign_reviewer(reviewer): assign a reviewer for this assignment team&lt;br /&gt;
* reviewed_by?(reviewer)：check if this assignment team is reviewed by this reviewer&lt;br /&gt;
* topic: get the topic picked up by this team&lt;br /&gt;
* has_submissions?: check if this team submitted work or not&lt;br /&gt;
* reviewed_contributor?(contributor)&lt;br /&gt;
* participants: get all the participants&lt;br /&gt;
* delete: delete the signed up users&lt;br /&gt;
* self.get_first_member(team_id): get the first participant&lt;br /&gt;
* get_hyperlinks&lt;br /&gt;
* get_path&lt;br /&gt;
* get_submitted_files&lt;br /&gt;
* get_review_map_type: return TeamReviewResponseMap&lt;br /&gt;
* self.handle_duplicate(team, name, assignment_id, handle_duplicates): handle duplicate team in different cases&lt;br /&gt;
* self.import(row,session,assignment_id,options): import team members to a exist team or a new team&lt;br /&gt;
* email： get fist team user's email&lt;br /&gt;
* get_participant_type: return AssignmentParticipant&lt;br /&gt;
* get_parent_model：return Assignment&lt;br /&gt;
* fullname&lt;br /&gt;
* get_participants&lt;br /&gt;
* copy(course_id): copy a team from course team&lt;br /&gt;
* add_participant(assignment_id, user): add participant to AssignmentParticipant&lt;br /&gt;
* assignment&lt;br /&gt;
* get_scores(questions): return a hash of scores that the team has received for the questions&lt;br /&gt;
* self.get_team(participant): get this participant's team&lt;br /&gt;
* self.export(csv, parent_id, options): export assignment and team members&lt;br /&gt;
* self.get_export_fields(options)&lt;br /&gt;
* self.create_team_and_node(assignment_id)&lt;br /&gt;
* self.remove_team_by_id(id): Remove a team given the team id&lt;br /&gt;
&lt;br /&gt;
=== app/unit/course_team.rb ===&lt;br /&gt;
* get_participant_type: return CourseParticipant&lt;br /&gt;
* get_parent_model：return Course&lt;br /&gt;
* get_node_type: return TeamNode&lt;br /&gt;
* assignment_id: return nil&lt;br /&gt;
* copy(assignment_id): copy a team from assignment team&lt;br /&gt;
* add_participant(course_id, user): add a user to a course. Note: this is deprecated because the functionality belongs to course&lt;br /&gt;
* export_participants: export the participants of a course team&lt;br /&gt;
* export(team_name_only): export team name, participants and course&lt;br /&gt;
* self.handle_duplicate(team, name, assignment_id, handle_duplicates): handle duplicate team in different cases&lt;br /&gt;
* self.import(row,session,assignment_id,options): import team members to a exist team or a new team&lt;br /&gt;
* self.export(csv, parent_id, options): export course and team members&lt;br /&gt;
* self.get_export_fields(options)&lt;br /&gt;
* self.export_all_assignment_team_related_to_course(csv, parent_id, options): this method is deprecated&lt;br /&gt;
* self.create_team_and_node(assignment_id)&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
* questions.yml&lt;br /&gt;
* signed_up_users.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
* remove&lt;br /&gt;
** test remove with valid user id&lt;br /&gt;
** test remove with invalid user id&lt;br /&gt;
&lt;br /&gt;
* create&lt;br /&gt;
** test create with valid user id&lt;br /&gt;
** test create with invalid user id&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
** test update with invalid id&lt;br /&gt;
** test update success&lt;br /&gt;
** test update fail (should remain the same)&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
** test edit&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* get participants&lt;br /&gt;
** test get participants&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
** test delete with team node&lt;br /&gt;
** test delete without team node&lt;br /&gt;
&lt;br /&gt;
* get_node_type &lt;br /&gt;
** test get node type&lt;br /&gt;
&lt;br /&gt;
* get_author_name&lt;br /&gt;
** test author name&lt;br /&gt;
&lt;br /&gt;
* generate_team_name() &lt;br /&gt;
** test generate team name from zero&lt;br /&gt;
** test generate team name from one&lt;br /&gt;
&lt;br /&gt;
* get_possible_team_members(name)&lt;br /&gt;
** test get possible team members by exact name&lt;br /&gt;
** test get possible team members by similar name&lt;br /&gt;
** test get possible team members by name in other team&lt;br /&gt;
&lt;br /&gt;
* has_user(user)&lt;br /&gt;
** test has user with valid user&lt;br /&gt;
** test has user with invalid user&lt;br /&gt;
&lt;br /&gt;
* add_member(user, assignment_id)&lt;br /&gt;
** test add member with valid user&lt;br /&gt;
** test add member already in team&lt;br /&gt;
** test add member without assignment id&lt;br /&gt;
** test add member when max team size reached&lt;br /&gt;
&lt;br /&gt;
* copy_members(new_team)&lt;br /&gt;
** test copy members to empty new team&lt;br /&gt;
** test copy members to nonempty new team&lt;br /&gt;
** test copy members with no member in current team&lt;br /&gt;
&lt;br /&gt;
* create_node_object(name, parent_id)&lt;br /&gt;
** ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
&lt;br /&gt;
* check_for_exisiting(parent, name, team_type)&lt;br /&gt;
** test check for exisiting with exisited name&lt;br /&gt;
** test check for exisiting with nonexisted name&lt;br /&gt;
&lt;br /&gt;
* delete_all_by_parent(parent)&lt;br /&gt;
** test delete with valid parents&lt;br /&gt;
** test delete with invalid parents&lt;br /&gt;
&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size)&lt;br /&gt;
** test randomize all by parent with exact number&lt;br /&gt;
** test randomize all by parent without enough people&lt;br /&gt;
** test randomize all by parent with remainder&lt;br /&gt;
&lt;br /&gt;
* generate_team_name(teamnameprefix)&lt;br /&gt;
** test generate prefix team name with valid name&lt;br /&gt;
** test generate prefix team name with duplicated name&lt;br /&gt;
&lt;br /&gt;
* import_team_members(starting_index, row) &lt;br /&gt;
** test import team members with valid index and row&lt;br /&gt;
** test import team members with invalid index and row&lt;br /&gt;
&lt;br /&gt;
=== assignment_team.rb ===&lt;br /&gt;
* includes?(participant)&lt;br /&gt;
** test one assignment team include a participant return true&lt;br /&gt;
* assign_reviewer(reviewer)&lt;br /&gt;
** assign a reviewer for this assignment team, and TeamReviewResponseMap.count increases&lt;br /&gt;
* reviewed_by?(reviewer)&lt;br /&gt;
** TeamReviewResponseMap is empty, so test this method will return false&lt;br /&gt;
* has_submissions?&lt;br /&gt;
** test one team has a submission return true&lt;br /&gt;
* reviewed_contributor?(contributor)&lt;br /&gt;
** TeamReviewResponseMap is empty, so test this method will return false&lt;br /&gt;
* participants&lt;br /&gt;
** participants are not nil&lt;br /&gt;
* delete&lt;br /&gt;
** this method has bug. No test&lt;br /&gt;
* self.get_first_member(team_id)&lt;br /&gt;
** test first menber not nil&lt;br /&gt;
* get_hyperlinks&lt;br /&gt;
** test hyperlinks are not nil&lt;br /&gt;
* get_path&lt;br /&gt;
** test path is not nil&lt;br /&gt;
* get_submitted_files&lt;br /&gt;
** submitted_file must be empty, expect nil&lt;br /&gt;
* get_review_map_type&lt;br /&gt;
** return TeamReviewResponseMap&lt;br /&gt;
* self.handle_duplicate(team, name, assignment_id, handle_duplicates)&lt;br /&gt;
** test in different cases(team is nil, option is &amp;quot;ignore&amp;quot;, option is &amp;quot;rename&amp;quot;)&lt;br /&gt;
* self.import(row,session,assignment_id,options)&lt;br /&gt;
** test in different cases(argument error, has_column_name is true, has_column_name is false)&lt;br /&gt;
* email&lt;br /&gt;
** this method has bug because there is no method named get_team_users. No test&lt;br /&gt;
* get_participant_type&lt;br /&gt;
** return AssignmentParticipant&lt;br /&gt;
* get_parent_model&lt;br /&gt;
** return Assignment&lt;br /&gt;
* fullname&lt;br /&gt;
** return value should equal what we expect&lt;br /&gt;
* get_participants&lt;br /&gt;
** test the participants are not nil&lt;br /&gt;
* copy(course_id)&lt;br /&gt;
** TeamUserNode.count and TeamsUser.count increase&lt;br /&gt;
* add_participant(assignment_id, user)&lt;br /&gt;
** AssignmentParticipant.count increases&lt;br /&gt;
* assignment&lt;br /&gt;
** return value should equal what we expect&lt;br /&gt;
* get_scores(questions)&lt;br /&gt;
** return output's total score is not nil and the assignment team is what we expect&lt;br /&gt;
* self.get_team(participant)&lt;br /&gt;
** return team is what we expect&lt;br /&gt;
* self.export(csv, parent_id, options)&lt;br /&gt;
** test in different cases(team_name is true, team_name is false)&lt;br /&gt;
* self.get_export_fields(options)&lt;br /&gt;
** test if the fields' name is right&lt;br /&gt;
* self.create_team_and_node(assignment_id)&lt;br /&gt;
** assignent team and team node are not nil&lt;br /&gt;
* self.remove_team_by_id(id)&lt;br /&gt;
** check the removed team cannot be found in AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
=== course_team.rb ===&lt;br /&gt;
Because most of the methods in course_team.rb are similar with that in assignment_team.rb if they have the same name. So I skip the same name method. Take the test/unit/course_team_test.rb as a reference.&lt;br /&gt;
* self.export_all_assignment_team_related_to_course(csv, parent_id, options)&lt;br /&gt;
** this method should be deleted here. No test&lt;br /&gt;
&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* There are two ''def get_participants'', the second one overwritten the first one, so the first one should be deleted.&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/unit/&amp;lt;filename&amp;gt; # for models&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/&amp;lt;filename&amp;gt; # for controllers&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84725</id>
		<title>CSC/ECE 517 Spring 2014/final doc updated qyx</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84725"/>
		<updated>2014-04-24T20:20:44Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: /* course_team.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
=== assignment_team.rb &amp;amp; course_team.rb ===&lt;br /&gt;
* Both assignment_team class and course_team class are inherited from team class.&lt;br /&gt;
* These two classes have similar methods, which could be used to manage teams for assignment and course more effectively.&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
The “team” object represents a team that consists students who are either participants of course or assignment.&lt;br /&gt;
a team will response to the request on: &lt;br /&gt;
&lt;br /&gt;
* get_participants : get participant in the team&lt;br /&gt;
* delete : delete a team member in the team&lt;br /&gt;
* get_node_type : will return “TeamNode”&lt;br /&gt;
* get_author_name : will return team’s name&lt;br /&gt;
* generate_team_name() : serialize the automatically generated team name (e.g. team 1, team 2, etc.)&lt;br /&gt;
* get_possible_team_members(name) : find a team member by name&lt;br /&gt;
* has_user(user : find a team member by user object&lt;br /&gt;
* add_member(user, assignment_id) : add a user to an assignment team&lt;br /&gt;
* copy_members(new_team) : copy current member in the team to the new team&lt;br /&gt;
* create_node_object(name, parent_id) : ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
* check_for_exisiting(parent, name, team_type) : check if the team name under the same assignment or course is in use.&lt;br /&gt;
* delete_all_by_parent(parent) : delete all teams under the same course/assignment&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size) : randomly assign team members&lt;br /&gt;
* generate_team_name(teamnameprefix) : generate team name with prefix (e.g. prefix_Team1) &lt;br /&gt;
* import_team_members(starting_index, row) : import user from specific index of users and length&lt;br /&gt;
&lt;br /&gt;
=== app/unit/assignment_team.rb ===&lt;br /&gt;
* includes?(participant): check if this assignment team include this participant&lt;br /&gt;
* assign_reviewer(reviewer): assign a reviewer for this assignment team&lt;br /&gt;
* reviewed_by?(reviewer)：check if this assignment team is reviewed by this reviewer&lt;br /&gt;
* topic: get the topic picked up by this team&lt;br /&gt;
* has_submissions?: check if this team submitted work or not&lt;br /&gt;
* reviewed_contributor?(contributor)&lt;br /&gt;
* participants: get all the participants&lt;br /&gt;
* delete: delete the signed up users&lt;br /&gt;
* self.get_first_member(team_id): get the first participant&lt;br /&gt;
* get_hyperlinks&lt;br /&gt;
* get_path&lt;br /&gt;
* get_submitted_files&lt;br /&gt;
* get_review_map_type: return TeamReviewResponseMap&lt;br /&gt;
* self.handle_duplicate(team, name, assignment_id, handle_duplicates): handle duplicate team in different cases&lt;br /&gt;
* self.import(row,session,assignment_id,options): import team members to a exist team or a new team&lt;br /&gt;
* email： get fist team user's email&lt;br /&gt;
* get_participant_type: return AssignmentParticipant&lt;br /&gt;
* get_parent_model：return Assignment&lt;br /&gt;
* fullname&lt;br /&gt;
* get_participants&lt;br /&gt;
* copy(course_id): copy a team from course team&lt;br /&gt;
* add_participant(assignment_id, user): add participant to AssignmentParticipant&lt;br /&gt;
* assignment&lt;br /&gt;
* get_scores(questions): return a hash of scores that the team has received for the questions&lt;br /&gt;
* self.get_team(participant): get this participant's team&lt;br /&gt;
* self.export(csv, parent_id, options): export assignment and team members&lt;br /&gt;
* self.get_export_fields(options)&lt;br /&gt;
* self.create_team_and_node(assignment_id)&lt;br /&gt;
* self.remove_team_by_id(id): Remove a team given the team id&lt;br /&gt;
&lt;br /&gt;
=== app/unit/course_team.rb ===&lt;br /&gt;
* get_participant_type: return CourseParticipant&lt;br /&gt;
* get_parent_model：return Course&lt;br /&gt;
* get_node_type: return TeamNode&lt;br /&gt;
* assignment_id: return nil&lt;br /&gt;
* copy(assignment_id): copy a team from assignment team&lt;br /&gt;
* add_participant(course_id, user): add a user to a course. Note: this is deprecated because the functionality belongs to course&lt;br /&gt;
* export_participants: export the participants of a course team&lt;br /&gt;
* export(team_name_only): export team name, participants and course&lt;br /&gt;
* self.handle_duplicate(team, name, assignment_id, handle_duplicates): handle duplicate team in different cases&lt;br /&gt;
* self.import(row,session,assignment_id,options): import team members to a exist team or a new team&lt;br /&gt;
* self.export(csv, parent_id, options): export course and team members&lt;br /&gt;
* self.get_export_fields(options)&lt;br /&gt;
* self.export_all_assignment_team_related_to_course(csv, parent_id, options): this method is deprecated&lt;br /&gt;
* self.create_team_and_node(assignment_id)&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
* questions.yml&lt;br /&gt;
* signed_up_users.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
* remove&lt;br /&gt;
** test remove with valid user id&lt;br /&gt;
** test remove with invalid user id&lt;br /&gt;
&lt;br /&gt;
* create&lt;br /&gt;
** test create with valid user id&lt;br /&gt;
** test create with invalid user id&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
** test update with invalid id&lt;br /&gt;
** test update success&lt;br /&gt;
** test update fail (should remain the same)&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
** test edit&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* get participants&lt;br /&gt;
** test get participants&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
** test delete with team node&lt;br /&gt;
** test delete without team node&lt;br /&gt;
&lt;br /&gt;
* get_node_type &lt;br /&gt;
** test get node type&lt;br /&gt;
&lt;br /&gt;
* get_author_name&lt;br /&gt;
** test author name&lt;br /&gt;
&lt;br /&gt;
* generate_team_name() &lt;br /&gt;
** test generate team name from zero&lt;br /&gt;
** test generate team name from one&lt;br /&gt;
&lt;br /&gt;
* get_possible_team_members(name)&lt;br /&gt;
** test get possible team members by exact name&lt;br /&gt;
** test get possible team members by similar name&lt;br /&gt;
** test get possible team members by name in other team&lt;br /&gt;
&lt;br /&gt;
* has_user(user)&lt;br /&gt;
** test has user with valid user&lt;br /&gt;
** test has user with invalid user&lt;br /&gt;
&lt;br /&gt;
* add_member(user, assignment_id)&lt;br /&gt;
** test add member with valid user&lt;br /&gt;
** test add member already in team&lt;br /&gt;
** test add member without assignment id&lt;br /&gt;
** test add member when max team size reached&lt;br /&gt;
&lt;br /&gt;
* copy_members(new_team)&lt;br /&gt;
** test copy members to empty new team&lt;br /&gt;
** test copy members to nonempty new team&lt;br /&gt;
** test copy members with no member in current team&lt;br /&gt;
&lt;br /&gt;
* create_node_object(name, parent_id)&lt;br /&gt;
** ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
&lt;br /&gt;
* check_for_exisiting(parent, name, team_type)&lt;br /&gt;
** test check for exisiting with exisited name&lt;br /&gt;
** test check for exisiting with nonexisted name&lt;br /&gt;
&lt;br /&gt;
* delete_all_by_parent(parent)&lt;br /&gt;
** test delete with valid parents&lt;br /&gt;
** test delete with invalid parents&lt;br /&gt;
&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size)&lt;br /&gt;
** test randomize all by parent with exact number&lt;br /&gt;
** test randomize all by parent without enough people&lt;br /&gt;
** test randomize all by parent with remainder&lt;br /&gt;
&lt;br /&gt;
* generate_team_name(teamnameprefix)&lt;br /&gt;
** test generate prefix team name with valid name&lt;br /&gt;
** test generate prefix team name with duplicated name&lt;br /&gt;
&lt;br /&gt;
* import_team_members(starting_index, row) &lt;br /&gt;
** test import team members with valid index and row&lt;br /&gt;
** test import team members with invalid index and row&lt;br /&gt;
&lt;br /&gt;
=== assignment_team.rb ===&lt;br /&gt;
* includes?(participant)&lt;br /&gt;
** test one assignment team include a participant return true&lt;br /&gt;
* assign_reviewer(reviewer)&lt;br /&gt;
** assign a reviewer for this assignment team, and TeamReviewResponseMap.count increases&lt;br /&gt;
* reviewed_by?(reviewer)&lt;br /&gt;
** TeamReviewResponseMap is empty, so test this method will return false&lt;br /&gt;
* has_submissions?&lt;br /&gt;
** test one team has a submission return true&lt;br /&gt;
* reviewed_contributor?(contributor)&lt;br /&gt;
** TeamReviewResponseMap is empty, so test this method will return false&lt;br /&gt;
* participants&lt;br /&gt;
** participants are not nil&lt;br /&gt;
* delete: delete the signed up users&lt;br /&gt;
** this method has bug. No test&lt;br /&gt;
* self.get_first_member(team_id): get the first participant&lt;br /&gt;
** first menber not nil&lt;br /&gt;
* get_hyperlinks&lt;br /&gt;
** test hyperlinks are not nil&lt;br /&gt;
* get_path&lt;br /&gt;
** test path is not nil&lt;br /&gt;
* get_submitted_files&lt;br /&gt;
** submitted_file must be empty, expect nil&lt;br /&gt;
* get_review_map_type&lt;br /&gt;
** return TeamReviewResponseMap&lt;br /&gt;
* self.handle_duplicate(team, name, assignment_id, handle_duplicates)&lt;br /&gt;
** test in different cases(team is nil, option is &amp;quot;ignore&amp;quot;, option is &amp;quot;rename&amp;quot;)&lt;br /&gt;
* self.import(row,session,assignment_id,options)&lt;br /&gt;
** test in different cases(argument error, has_column_name is true, has_column_name is false)&lt;br /&gt;
* email： get fist team user's email&lt;br /&gt;
** this method is wrong because there is no methond named get_team_users. No test&lt;br /&gt;
* get_participant_type&lt;br /&gt;
** return AssignmentParticipant&lt;br /&gt;
* get_parent_model&lt;br /&gt;
** return Assignment&lt;br /&gt;
* fullname&lt;br /&gt;
** return value should equal what we expect&lt;br /&gt;
* get_participants&lt;br /&gt;
** test the participants are not nil&lt;br /&gt;
* copy(course_id): copy a team from course team&lt;br /&gt;
** TeamUserNode.count and TeamsUser.count increase&lt;br /&gt;
* add_participant(assignment_id, user)&lt;br /&gt;
** AssignmentParticipant.count increases&lt;br /&gt;
* assignment&lt;br /&gt;
** return value should equal what we expect&lt;br /&gt;
* get_scores(questions)&lt;br /&gt;
** return output's total score is not nil and the assignment team is what we expect&lt;br /&gt;
* self.get_team(participant): get this participant's team&lt;br /&gt;
** return team is what we expect&lt;br /&gt;
* self.export(csv, parent_id, options)&lt;br /&gt;
** test in different cases(team_name is true, team_name is false)&lt;br /&gt;
* self.get_export_fields(options)&lt;br /&gt;
** test if the fields' name is right&lt;br /&gt;
* self.create_team_and_node(assignment_id)&lt;br /&gt;
** assignent team and team node are not nil&lt;br /&gt;
* self.remove_team_by_id(id)&lt;br /&gt;
** check the removed team cannot be found in AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
=== course_team.rb ===&lt;br /&gt;
Because most of the methods in course_team.rb are similar with that in assignment_team.rb if they have the same name. So I skip the same name method. Take the test/unit/course_team_test.rb as a reference.&lt;br /&gt;
* self.export_all_assignment_team_related_to_course(csv, parent_id, options)&lt;br /&gt;
** this method should be deleted here. No test&lt;br /&gt;
&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* There are two ''def get_participants'', the second one overwritten the first one, so the first one should be deleted.&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/unit/&amp;lt;filename&amp;gt; # for models&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/&amp;lt;filename&amp;gt; # for controllers&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84724</id>
		<title>CSC/ECE 517 Spring 2014/final doc updated qyx</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84724"/>
		<updated>2014-04-24T20:16:19Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: /* assignment_team.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
=== assignment_team.rb &amp;amp; course_team.rb ===&lt;br /&gt;
* Both assignment_team class and course_team class are inherited from team class.&lt;br /&gt;
* These two classes have similar methods, which could be used to manage teams for assignment and course more effectively.&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
The “team” object represents a team that consists students who are either participants of course or assignment.&lt;br /&gt;
a team will response to the request on: &lt;br /&gt;
&lt;br /&gt;
* get_participants : get participant in the team&lt;br /&gt;
* delete : delete a team member in the team&lt;br /&gt;
* get_node_type : will return “TeamNode”&lt;br /&gt;
* get_author_name : will return team’s name&lt;br /&gt;
* generate_team_name() : serialize the automatically generated team name (e.g. team 1, team 2, etc.)&lt;br /&gt;
* get_possible_team_members(name) : find a team member by name&lt;br /&gt;
* has_user(user : find a team member by user object&lt;br /&gt;
* add_member(user, assignment_id) : add a user to an assignment team&lt;br /&gt;
* copy_members(new_team) : copy current member in the team to the new team&lt;br /&gt;
* create_node_object(name, parent_id) : ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
* check_for_exisiting(parent, name, team_type) : check if the team name under the same assignment or course is in use.&lt;br /&gt;
* delete_all_by_parent(parent) : delete all teams under the same course/assignment&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size) : randomly assign team members&lt;br /&gt;
* generate_team_name(teamnameprefix) : generate team name with prefix (e.g. prefix_Team1) &lt;br /&gt;
* import_team_members(starting_index, row) : import user from specific index of users and length&lt;br /&gt;
&lt;br /&gt;
=== app/unit/assignment_team.rb ===&lt;br /&gt;
* includes?(participant): check if this assignment team include this participant&lt;br /&gt;
* assign_reviewer(reviewer): assign a reviewer for this assignment team&lt;br /&gt;
* reviewed_by?(reviewer)：check if this assignment team is reviewed by this reviewer&lt;br /&gt;
* topic: get the topic picked up by this team&lt;br /&gt;
* has_submissions?: check if this team submitted work or not&lt;br /&gt;
* reviewed_contributor?(contributor)&lt;br /&gt;
* participants: get all the participants&lt;br /&gt;
* delete: delete the signed up users&lt;br /&gt;
* self.get_first_member(team_id): get the first participant&lt;br /&gt;
* get_hyperlinks&lt;br /&gt;
* get_path&lt;br /&gt;
* get_submitted_files&lt;br /&gt;
* get_review_map_type: return TeamReviewResponseMap&lt;br /&gt;
* self.handle_duplicate(team, name, assignment_id, handle_duplicates): handle duplicate team in different cases&lt;br /&gt;
* self.import(row,session,assignment_id,options): import team members to a exist team or a new team&lt;br /&gt;
* email： get fist team user's email&lt;br /&gt;
* get_participant_type: return AssignmentParticipant&lt;br /&gt;
* get_parent_model：return Assignment&lt;br /&gt;
* fullname&lt;br /&gt;
* get_participants&lt;br /&gt;
* copy(course_id): copy a team from course team&lt;br /&gt;
* add_participant(assignment_id, user): add participant to AssignmentParticipant&lt;br /&gt;
* assignment&lt;br /&gt;
* get_scores(questions): return a hash of scores that the team has received for the questions&lt;br /&gt;
* self.get_team(participant): get this participant's team&lt;br /&gt;
* self.export(csv, parent_id, options): export assignment and team members&lt;br /&gt;
* self.get_export_fields(options)&lt;br /&gt;
* self.create_team_and_node(assignment_id)&lt;br /&gt;
* self.remove_team_by_id(id): Remove a team given the team id&lt;br /&gt;
&lt;br /&gt;
=== app/unit/course_team.rb ===&lt;br /&gt;
* get_participant_type: return CourseParticipant&lt;br /&gt;
* get_parent_model：return Course&lt;br /&gt;
* get_node_type: return TeamNode&lt;br /&gt;
* assignment_id: return nil&lt;br /&gt;
* copy(assignment_id): copy a team from assignment team&lt;br /&gt;
* add_participant(course_id, user): add a user to a course. Note: this is deprecated because the functionality belongs to course&lt;br /&gt;
* export_participants: export the participants of a course team&lt;br /&gt;
* export(team_name_only): export team name, participants and course&lt;br /&gt;
* self.handle_duplicate(team, name, assignment_id, handle_duplicates): handle duplicate team in different cases&lt;br /&gt;
* self.import(row,session,assignment_id,options): import team members to a exist team or a new team&lt;br /&gt;
* self.export(csv, parent_id, options): export course and team members&lt;br /&gt;
* self.get_export_fields(options)&lt;br /&gt;
* self.export_all_assignment_team_related_to_course(csv, parent_id, options): this method is deprecated&lt;br /&gt;
* self.create_team_and_node(assignment_id)&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
* questions.yml&lt;br /&gt;
* signed_up_users.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
* remove&lt;br /&gt;
** test remove with valid user id&lt;br /&gt;
** test remove with invalid user id&lt;br /&gt;
&lt;br /&gt;
* create&lt;br /&gt;
** test create with valid user id&lt;br /&gt;
** test create with invalid user id&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
** test update with invalid id&lt;br /&gt;
** test update success&lt;br /&gt;
** test update fail (should remain the same)&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
** test edit&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* get participants&lt;br /&gt;
** test get participants&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
** test delete with team node&lt;br /&gt;
** test delete without team node&lt;br /&gt;
&lt;br /&gt;
* get_node_type &lt;br /&gt;
** test get node type&lt;br /&gt;
&lt;br /&gt;
* get_author_name&lt;br /&gt;
** test author name&lt;br /&gt;
&lt;br /&gt;
* generate_team_name() &lt;br /&gt;
** test generate team name from zero&lt;br /&gt;
** test generate team name from one&lt;br /&gt;
&lt;br /&gt;
* get_possible_team_members(name)&lt;br /&gt;
** test get possible team members by exact name&lt;br /&gt;
** test get possible team members by similar name&lt;br /&gt;
** test get possible team members by name in other team&lt;br /&gt;
&lt;br /&gt;
* has_user(user)&lt;br /&gt;
** test has user with valid user&lt;br /&gt;
** test has user with invalid user&lt;br /&gt;
&lt;br /&gt;
* add_member(user, assignment_id)&lt;br /&gt;
** test add member with valid user&lt;br /&gt;
** test add member already in team&lt;br /&gt;
** test add member without assignment id&lt;br /&gt;
** test add member when max team size reached&lt;br /&gt;
&lt;br /&gt;
* copy_members(new_team)&lt;br /&gt;
** test copy members to empty new team&lt;br /&gt;
** test copy members to nonempty new team&lt;br /&gt;
** test copy members with no member in current team&lt;br /&gt;
&lt;br /&gt;
* create_node_object(name, parent_id)&lt;br /&gt;
** ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
&lt;br /&gt;
* check_for_exisiting(parent, name, team_type)&lt;br /&gt;
** test check for exisiting with exisited name&lt;br /&gt;
** test check for exisiting with nonexisted name&lt;br /&gt;
&lt;br /&gt;
* delete_all_by_parent(parent)&lt;br /&gt;
** test delete with valid parents&lt;br /&gt;
** test delete with invalid parents&lt;br /&gt;
&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size)&lt;br /&gt;
** test randomize all by parent with exact number&lt;br /&gt;
** test randomize all by parent without enough people&lt;br /&gt;
** test randomize all by parent with remainder&lt;br /&gt;
&lt;br /&gt;
* generate_team_name(teamnameprefix)&lt;br /&gt;
** test generate prefix team name with valid name&lt;br /&gt;
** test generate prefix team name with duplicated name&lt;br /&gt;
&lt;br /&gt;
* import_team_members(starting_index, row) &lt;br /&gt;
** test import team members with valid index and row&lt;br /&gt;
** test import team members with invalid index and row&lt;br /&gt;
&lt;br /&gt;
=== assignment_team.rb ===&lt;br /&gt;
* includes?(participant)&lt;br /&gt;
** test one assignment team include a participant return true&lt;br /&gt;
* assign_reviewer(reviewer)&lt;br /&gt;
** assign a reviewer for this assignment team, and TeamReviewResponseMap.count increases&lt;br /&gt;
* reviewed_by?(reviewer)&lt;br /&gt;
** TeamReviewResponseMap is empty, so test this method will return false&lt;br /&gt;
* has_submissions?&lt;br /&gt;
** test one team has a submission return true&lt;br /&gt;
* reviewed_contributor?(contributor)&lt;br /&gt;
** TeamReviewResponseMap is empty, so test this method will return false&lt;br /&gt;
* participants&lt;br /&gt;
** participants are not nil&lt;br /&gt;
* delete: delete the signed up users&lt;br /&gt;
** this method has bug. No test&lt;br /&gt;
* self.get_first_member(team_id): get the first participant&lt;br /&gt;
** first menber not nil&lt;br /&gt;
* get_hyperlinks&lt;br /&gt;
** test hyperlinks are not nil&lt;br /&gt;
* get_path&lt;br /&gt;
** test path is not nil&lt;br /&gt;
* get_submitted_files&lt;br /&gt;
** submitted_file must be empty, expect nil&lt;br /&gt;
* get_review_map_type&lt;br /&gt;
** return TeamReviewResponseMap&lt;br /&gt;
* self.handle_duplicate(team, name, assignment_id, handle_duplicates)&lt;br /&gt;
** test in different cases(team is nil, option is &amp;quot;ignore&amp;quot;, option is &amp;quot;rename&amp;quot;)&lt;br /&gt;
* self.import(row,session,assignment_id,options)&lt;br /&gt;
** test in different cases(argument error, has_column_name is true, has_column_name is false)&lt;br /&gt;
* email： get fist team user's email&lt;br /&gt;
** this method is wrong because there is no methond named get_team_users. No test&lt;br /&gt;
* get_participant_type&lt;br /&gt;
** return AssignmentParticipant&lt;br /&gt;
* get_parent_model&lt;br /&gt;
** return Assignment&lt;br /&gt;
* fullname&lt;br /&gt;
** return value should equal what we expect&lt;br /&gt;
* get_participants&lt;br /&gt;
** test the participants are not nil&lt;br /&gt;
* copy(course_id): copy a team from course team&lt;br /&gt;
** TeamUserNode.count and TeamsUser.count increase&lt;br /&gt;
* add_participant(assignment_id, user)&lt;br /&gt;
** AssignmentParticipant.count increases&lt;br /&gt;
* assignment&lt;br /&gt;
** return value should equal what we expect&lt;br /&gt;
* get_scores(questions)&lt;br /&gt;
** return output's total score is not nil and the assignment team is what we expect&lt;br /&gt;
* self.get_team(participant): get this participant's team&lt;br /&gt;
** return team is what we expect&lt;br /&gt;
* self.export(csv, parent_id, options)&lt;br /&gt;
** test in different cases(team_name is true, team_name is false)&lt;br /&gt;
* self.get_export_fields(options)&lt;br /&gt;
** test if the fields' name is right&lt;br /&gt;
* self.create_team_and_node(assignment_id)&lt;br /&gt;
** assignent team and team node are not nil&lt;br /&gt;
* self.remove_team_by_id(id)&lt;br /&gt;
** check the removed team cannot be found in AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
=== course_team.rb ===&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* There are two ''def get_participants'', the second one overwritten the first one, so the first one should be deleted.&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/unit/&amp;lt;filename&amp;gt; # for models&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/&amp;lt;filename&amp;gt; # for controllers&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84723</id>
		<title>CSC/ECE 517 Spring 2014/final doc updated qyx</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84723"/>
		<updated>2014-04-24T20:09:04Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
=== assignment_team.rb &amp;amp; course_team.rb ===&lt;br /&gt;
* Both assignment_team class and course_team class are inherited from team class.&lt;br /&gt;
* These two classes have similar methods, which could be used to manage teams for assignment and course more effectively.&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
The “team” object represents a team that consists students who are either participants of course or assignment.&lt;br /&gt;
a team will response to the request on: &lt;br /&gt;
&lt;br /&gt;
* get_participants : get participant in the team&lt;br /&gt;
* delete : delete a team member in the team&lt;br /&gt;
* get_node_type : will return “TeamNode”&lt;br /&gt;
* get_author_name : will return team’s name&lt;br /&gt;
* generate_team_name() : serialize the automatically generated team name (e.g. team 1, team 2, etc.)&lt;br /&gt;
* get_possible_team_members(name) : find a team member by name&lt;br /&gt;
* has_user(user : find a team member by user object&lt;br /&gt;
* add_member(user, assignment_id) : add a user to an assignment team&lt;br /&gt;
* copy_members(new_team) : copy current member in the team to the new team&lt;br /&gt;
* create_node_object(name, parent_id) : ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
* check_for_exisiting(parent, name, team_type) : check if the team name under the same assignment or course is in use.&lt;br /&gt;
* delete_all_by_parent(parent) : delete all teams under the same course/assignment&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size) : randomly assign team members&lt;br /&gt;
* generate_team_name(teamnameprefix) : generate team name with prefix (e.g. prefix_Team1) &lt;br /&gt;
* import_team_members(starting_index, row) : import user from specific index of users and length&lt;br /&gt;
&lt;br /&gt;
=== app/unit/assignment_team.rb ===&lt;br /&gt;
* includes?(participant): check if this assignment team include this participant&lt;br /&gt;
* assign_reviewer(reviewer): assign a reviewer for this assignment team&lt;br /&gt;
* reviewed_by?(reviewer)：check if this assignment team is reviewed by this reviewer&lt;br /&gt;
* topic: get the topic picked up by this team&lt;br /&gt;
* has_submissions?: check if this team submitted work or not&lt;br /&gt;
* reviewed_contributor?(contributor)&lt;br /&gt;
* participants: get all the participants&lt;br /&gt;
* delete: delete the signed up users&lt;br /&gt;
* self.get_first_member(team_id): get the first participant&lt;br /&gt;
* get_hyperlinks&lt;br /&gt;
* get_path&lt;br /&gt;
* get_submitted_files&lt;br /&gt;
* get_review_map_type: return TeamReviewResponseMap&lt;br /&gt;
* self.handle_duplicate(team, name, assignment_id, handle_duplicates): handle duplicate team in different cases&lt;br /&gt;
* self.import(row,session,assignment_id,options): import team members to a exist team or a new team&lt;br /&gt;
* email： get fist team user's email&lt;br /&gt;
* get_participant_type: return AssignmentParticipant&lt;br /&gt;
* get_parent_model：return Assignment&lt;br /&gt;
* fullname&lt;br /&gt;
* get_participants&lt;br /&gt;
* copy(course_id): copy a team from course team&lt;br /&gt;
* add_participant(assignment_id, user): add participant to AssignmentParticipant&lt;br /&gt;
* assignment&lt;br /&gt;
* get_scores(questions): return a hash of scores that the team has received for the questions&lt;br /&gt;
* self.get_team(participant): get this participant's team&lt;br /&gt;
* self.export(csv, parent_id, options): export assignment and team members&lt;br /&gt;
* self.get_export_fields(options)&lt;br /&gt;
* self.create_team_and_node(assignment_id)&lt;br /&gt;
* self.remove_team_by_id(id): Remove a team given the team id&lt;br /&gt;
&lt;br /&gt;
=== app/unit/course_team.rb ===&lt;br /&gt;
* get_participant_type: return CourseParticipant&lt;br /&gt;
* get_parent_model：return Course&lt;br /&gt;
* get_node_type: return TeamNode&lt;br /&gt;
* assignment_id: return nil&lt;br /&gt;
* copy(assignment_id): copy a team from assignment team&lt;br /&gt;
* add_participant(course_id, user): add a user to a course. Note: this is deprecated because the functionality belongs to course&lt;br /&gt;
* export_participants: export the participants of a course team&lt;br /&gt;
* export(team_name_only): export team name, participants and course&lt;br /&gt;
* self.handle_duplicate(team, name, assignment_id, handle_duplicates): handle duplicate team in different cases&lt;br /&gt;
* self.import(row,session,assignment_id,options): import team members to a exist team or a new team&lt;br /&gt;
* self.export(csv, parent_id, options): export course and team members&lt;br /&gt;
* self.get_export_fields(options)&lt;br /&gt;
* self.export_all_assignment_team_related_to_course(csv, parent_id, options): this method is deprecated&lt;br /&gt;
* self.create_team_and_node(assignment_id)&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
* questions.yml&lt;br /&gt;
* signed_up_users.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
* remove&lt;br /&gt;
** test remove with valid user id&lt;br /&gt;
** test remove with invalid user id&lt;br /&gt;
&lt;br /&gt;
* create&lt;br /&gt;
** test create with valid user id&lt;br /&gt;
** test create with invalid user id&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
** test update with invalid id&lt;br /&gt;
** test update success&lt;br /&gt;
** test update fail (should remain the same)&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
** test edit&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* get participants&lt;br /&gt;
** test get participants&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
** test delete with team node&lt;br /&gt;
** test delete without team node&lt;br /&gt;
&lt;br /&gt;
* get_node_type &lt;br /&gt;
** test get node type&lt;br /&gt;
&lt;br /&gt;
* get_author_name&lt;br /&gt;
** test author name&lt;br /&gt;
&lt;br /&gt;
* generate_team_name() &lt;br /&gt;
** test generate team name from zero&lt;br /&gt;
** test generate team name from one&lt;br /&gt;
&lt;br /&gt;
* get_possible_team_members(name)&lt;br /&gt;
** test get possible team members by exact name&lt;br /&gt;
** test get possible team members by similar name&lt;br /&gt;
** test get possible team members by name in other team&lt;br /&gt;
&lt;br /&gt;
* has_user(user)&lt;br /&gt;
** test has user with valid user&lt;br /&gt;
** test has user with invalid user&lt;br /&gt;
&lt;br /&gt;
* add_member(user, assignment_id)&lt;br /&gt;
** test add member with valid user&lt;br /&gt;
** test add member already in team&lt;br /&gt;
** test add member without assignment id&lt;br /&gt;
** test add member when max team size reached&lt;br /&gt;
&lt;br /&gt;
* copy_members(new_team)&lt;br /&gt;
** test copy members to empty new team&lt;br /&gt;
** test copy members to nonempty new team&lt;br /&gt;
** test copy members with no member in current team&lt;br /&gt;
&lt;br /&gt;
* create_node_object(name, parent_id)&lt;br /&gt;
** ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
&lt;br /&gt;
* check_for_exisiting(parent, name, team_type)&lt;br /&gt;
** test check for exisiting with exisited name&lt;br /&gt;
** test check for exisiting with nonexisted name&lt;br /&gt;
&lt;br /&gt;
* delete_all_by_parent(parent)&lt;br /&gt;
** test delete with valid parents&lt;br /&gt;
** test delete with invalid parents&lt;br /&gt;
&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size)&lt;br /&gt;
** test randomize all by parent with exact number&lt;br /&gt;
** test randomize all by parent without enough people&lt;br /&gt;
** test randomize all by parent with remainder&lt;br /&gt;
&lt;br /&gt;
* generate_team_name(teamnameprefix)&lt;br /&gt;
** test generate prefix team name with valid name&lt;br /&gt;
** test generate prefix team name with duplicated name&lt;br /&gt;
&lt;br /&gt;
* import_team_members(starting_index, row) &lt;br /&gt;
** test import team members with valid index and row&lt;br /&gt;
** test import team members with invalid index and row&lt;br /&gt;
&lt;br /&gt;
=== assignment_team.rb ===&lt;br /&gt;
* includes?(participant)&lt;br /&gt;
** test one assignment team include a participant return true&lt;br /&gt;
* assign_reviewer(reviewer)&lt;br /&gt;
** assign a reviewer for this assignment team, and TeamReviewResponseMap.count increases&lt;br /&gt;
* reviewed_by?(reviewer)&lt;br /&gt;
** TeamReviewResponseMap is empty, so test this method will return false&lt;br /&gt;
* has_submissions?&lt;br /&gt;
** test one team has a submission return true&lt;br /&gt;
* reviewed_contributor?(contributor)&lt;br /&gt;
** TeamReviewResponseMap is empty, so test this method will return false&lt;br /&gt;
* participants&lt;br /&gt;
** participants are not nil&lt;br /&gt;
* delete: delete the signed up users&lt;br /&gt;
* self.get_first_member(team_id): get the first participant&lt;br /&gt;
** first menber not nil&lt;br /&gt;
* get_hyperlinks&lt;br /&gt;
** test hyperlinks are not nil&lt;br /&gt;
* get_path&lt;br /&gt;
** test path is not nil&lt;br /&gt;
* get_submitted_files&lt;br /&gt;
** submitted_file must be empty, expect nil&lt;br /&gt;
* get_review_map_type: return TeamReviewResponseMap&lt;br /&gt;
* self.handle_duplicate(team, name, assignment_id, handle_duplicates)&lt;br /&gt;
** test in different cases(team is nil, option is &amp;quot;ignore&amp;quot;, option is &amp;quot;rename&amp;quot;)&lt;br /&gt;
* self.import(row,session,assignment_id,options)&lt;br /&gt;
** test in different cases(argument error, has_column_name is true, has_column_name is false)&lt;br /&gt;
* email： get fist team user's email&lt;br /&gt;
* get_participant_type&lt;br /&gt;
** return AssignmentParticipant&lt;br /&gt;
* get_parent_model&lt;br /&gt;
** return Assignment&lt;br /&gt;
* fullname&lt;br /&gt;
** return value should equal what we expect&lt;br /&gt;
* get_participants&lt;br /&gt;
** test the participants are not nil&lt;br /&gt;
* copy(course_id): copy a team from course team&lt;br /&gt;
** TeamUserNode.count and TeamsUser.count increase&lt;br /&gt;
* add_participant(assignment_id, user)&lt;br /&gt;
** AssignmentParticipant.count increases&lt;br /&gt;
* assignment&lt;br /&gt;
** return value should equal what we expect&lt;br /&gt;
* get_scores(questions): return a hash of scores that the team has received for the questions&lt;br /&gt;
* self.get_team(participant): get this participant's team&lt;br /&gt;
* self.export(csv, parent_id, options)&lt;br /&gt;
** test in different cases(team_name is true, team_name is false)&lt;br /&gt;
* self.get_export_fields(options)&lt;br /&gt;
** test if the fields name is right&lt;br /&gt;
* self.create_team_and_node(assignment_id)&lt;br /&gt;
** assignent team and team node are not nil&lt;br /&gt;
* self.remove_team_by_id(id): Remove a team given the team id&lt;br /&gt;
=== course_team.rb ===&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* There are two ''def get_participants'', the second one overwritten the first one, so the first one should be deleted.&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/unit/&amp;lt;filename&amp;gt; # for models&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/&amp;lt;filename&amp;gt; # for controllers&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84722</id>
		<title>CSC/ECE 517 Spring 2014/final doc updated qyx</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84722"/>
		<updated>2014-04-24T19:37:12Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
=== assignment_team.rb &amp;amp; course_team.rb ===&lt;br /&gt;
* Both assignment_team class and course_team class are inherited from team class.&lt;br /&gt;
* These two classes have similar methods, which could be used to manage teams for assignment and course more effectively.&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
The “team” object represents a team that consists students who are either participants of course or assignment.&lt;br /&gt;
a team will response to the request on: &lt;br /&gt;
&lt;br /&gt;
* get_participants : get participant in the team&lt;br /&gt;
* delete : delete a team member in the team&lt;br /&gt;
* get_node_type : will return “TeamNode”&lt;br /&gt;
* get_author_name : will return team’s name&lt;br /&gt;
* generate_team_name() : serialize the automatically generated team name (e.g. team 1, team 2, etc.)&lt;br /&gt;
* get_possible_team_members(name) : find a team member by name&lt;br /&gt;
* has_user(user : find a team member by user object&lt;br /&gt;
* add_member(user, assignment_id) : add a user to an assignment team&lt;br /&gt;
* copy_members(new_team) : copy current member in the team to the new team&lt;br /&gt;
* create_node_object(name, parent_id) : ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
* check_for_exisiting(parent, name, team_type) : check if the team name under the same assignment or course is in use.&lt;br /&gt;
* delete_all_by_parent(parent) : delete all teams under the same course/assignment&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size) : randomly assign team members&lt;br /&gt;
* generate_team_name(teamnameprefix) : generate team name with prefix (e.g. prefix_Team1) &lt;br /&gt;
* import_team_members(starting_index, row) : import user from specific index of users and length&lt;br /&gt;
&lt;br /&gt;
=== app/unit/assignment_team.rb ===&lt;br /&gt;
* includes?(participant): check if this assignment team include this participant&lt;br /&gt;
* assign_reviewer(reviewer): assign a reviewer for this assignment team&lt;br /&gt;
* reviewed_by?(reviewer)：check if this assignment team is reviewed by this reviewer&lt;br /&gt;
* topic: get the topic picked up by this team&lt;br /&gt;
* has_submissions?: check if this team submitted work or not&lt;br /&gt;
* reviewed_contributor?(contributor)&lt;br /&gt;
* participants: get all the participants&lt;br /&gt;
* delete: delete the signed up users&lt;br /&gt;
* self.get_first_member(team_id): get the first participant&lt;br /&gt;
* get_hyperlinks&lt;br /&gt;
* get_path&lt;br /&gt;
* get_submitted_files&lt;br /&gt;
* get_review_map_type: return TeamReviewResponseMap&lt;br /&gt;
* self.handle_duplicate(team, name, assignment_id, handle_duplicates): handle duplicate team in different cases&lt;br /&gt;
* self.import(row,session,assignment_id,options): import team members to a exist team or a new team&lt;br /&gt;
* email： get fist team user's email&lt;br /&gt;
* get_participant_type: return AssignmentParticipant&lt;br /&gt;
* get_parent_model：return Assignment&lt;br /&gt;
* fullname&lt;br /&gt;
* get_participants&lt;br /&gt;
* copy(course_id): copy a team from course team&lt;br /&gt;
* add_participant(assignment_id, user): add participant to AssignmentParticipant&lt;br /&gt;
* assignment&lt;br /&gt;
* get_scores(questions): return a hash of scores that the team has received for the questions&lt;br /&gt;
* self.get_team(participant): get this participant's team&lt;br /&gt;
* self.export(csv, parent_id, options): export assignment and team members&lt;br /&gt;
* self.get_export_fields(options)&lt;br /&gt;
* self.create_team_and_node(assignment_id)&lt;br /&gt;
* self.remove_team_by_id(id): Remove a team given the team id&lt;br /&gt;
&lt;br /&gt;
=== app/unit/course_team.rb ===&lt;br /&gt;
* get_participant_type: return CourseParticipant&lt;br /&gt;
* get_parent_model：return Course&lt;br /&gt;
* get_node_type: return TeamNode&lt;br /&gt;
* assignment_id: return nil&lt;br /&gt;
* copy(assignment_id): copy a team from assignment team&lt;br /&gt;
* add_participant(course_id, user): add a user to a course. Note: this is deprecated because the functionality belongs to course&lt;br /&gt;
* export_participants: export the participants of a course team&lt;br /&gt;
* export(team_name_only): export team name, participants and course&lt;br /&gt;
* self.handle_duplicate(team, name, assignment_id, handle_duplicates): handle duplicate team in different cases&lt;br /&gt;
* self.import(row,session,assignment_id,options): import team members to a exist team or a new team&lt;br /&gt;
* self.export(csv, parent_id, options): export course and team members&lt;br /&gt;
* self.get_export_fields(options)&lt;br /&gt;
* self.export_all_assignment_team_related_to_course(csv, parent_id, options): this method is deprecated&lt;br /&gt;
* self.create_team_and_node(assignment_id)&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
* questions.yml&lt;br /&gt;
* signed_up_users.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
* remove&lt;br /&gt;
** test remove with valid user id&lt;br /&gt;
** test remove with invalid user id&lt;br /&gt;
&lt;br /&gt;
* create&lt;br /&gt;
** test create with valid user id&lt;br /&gt;
** test create with invalid user id&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
** test update with invalid id&lt;br /&gt;
** test update success&lt;br /&gt;
** test update fail (should remain the same)&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
** test edit&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* get participants&lt;br /&gt;
** test get participants&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
** test delete with team node&lt;br /&gt;
** test delete without team node&lt;br /&gt;
&lt;br /&gt;
* get_node_type &lt;br /&gt;
** test get node type&lt;br /&gt;
&lt;br /&gt;
* get_author_name&lt;br /&gt;
** test author name&lt;br /&gt;
&lt;br /&gt;
* generate_team_name() &lt;br /&gt;
** test generate team name from zero&lt;br /&gt;
** test generate team name from one&lt;br /&gt;
&lt;br /&gt;
* get_possible_team_members(name)&lt;br /&gt;
** test get possible team members by exact name&lt;br /&gt;
** test get possible team members by similar name&lt;br /&gt;
** test get possible team members by name in other team&lt;br /&gt;
&lt;br /&gt;
* has_user(user)&lt;br /&gt;
** test has user with valid user&lt;br /&gt;
** test has user with invalid user&lt;br /&gt;
&lt;br /&gt;
* add_member(user, assignment_id)&lt;br /&gt;
** test add member with valid user&lt;br /&gt;
** test add member already in team&lt;br /&gt;
** test add member without assignment id&lt;br /&gt;
** test add member when max team size reached&lt;br /&gt;
&lt;br /&gt;
* copy_members(new_team)&lt;br /&gt;
** test copy members to empty new team&lt;br /&gt;
** test copy members to nonempty new team&lt;br /&gt;
** test copy members with no member in current team&lt;br /&gt;
&lt;br /&gt;
* create_node_object(name, parent_id)&lt;br /&gt;
** ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
&lt;br /&gt;
* check_for_exisiting(parent, name, team_type)&lt;br /&gt;
** test check for exisiting with exisited name&lt;br /&gt;
** test check for exisiting with nonexisted name&lt;br /&gt;
&lt;br /&gt;
* delete_all_by_parent(parent)&lt;br /&gt;
** test delete with valid parents&lt;br /&gt;
** test delete with invalid parents&lt;br /&gt;
&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size)&lt;br /&gt;
** test randomize all by parent with exact number&lt;br /&gt;
** test randomize all by parent without enough people&lt;br /&gt;
** test randomize all by parent with remainder&lt;br /&gt;
&lt;br /&gt;
* generate_team_name(teamnameprefix)&lt;br /&gt;
** test generate prefix team name with valid name&lt;br /&gt;
** test generate prefix team name with duplicated name&lt;br /&gt;
&lt;br /&gt;
* import_team_members(starting_index, row) &lt;br /&gt;
** test import team members with valid index and row&lt;br /&gt;
** test import team members with invalid index and row&lt;br /&gt;
&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* There are two ''def get_participants'', the second one overwritten the first one, so the first one should be deleted.&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/unit/&amp;lt;filename&amp;gt; # for models&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/&amp;lt;filename&amp;gt; # for controllers&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84721</id>
		<title>CSC/ECE 517 Spring 2014/final doc updated qyx</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84721"/>
		<updated>2014-04-24T19:23:48Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
=== assignment_team.rb &amp;amp; course_team.rb ===&lt;br /&gt;
* Both assignment_team class and course_team class are inherited from team class.&lt;br /&gt;
* These two classes have similar methods, which could be used to manage teams for assignment and course more effectively.&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
The “team” object represents a team that consists students who are either participants of course or assignment.&lt;br /&gt;
a team will response to the request on: &lt;br /&gt;
&lt;br /&gt;
* get_participants : get participant in the team&lt;br /&gt;
* delete : delete a team member in the team&lt;br /&gt;
* get_node_type : will return “TeamNode”&lt;br /&gt;
* get_author_name : will return team’s name&lt;br /&gt;
* generate_team_name() : serialize the automatically generated team name (e.g. team 1, team 2, etc.)&lt;br /&gt;
* get_possible_team_members(name) : find a team member by name&lt;br /&gt;
* has_user(user : find a team member by user object&lt;br /&gt;
* add_member(user, assignment_id) : add a user to an assignment team&lt;br /&gt;
* copy_members(new_team) : copy current member in the team to the new team&lt;br /&gt;
* create_node_object(name, parent_id) : ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
* check_for_exisiting(parent, name, team_type) : check if the team name under the same assignment or course is in use.&lt;br /&gt;
* delete_all_by_parent(parent) : delete all teams under the same course/assignment&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size) : randomly assign team members&lt;br /&gt;
* generate_team_name(teamnameprefix) : generate team name with prefix (e.g. prefix_Team1) &lt;br /&gt;
* import_team_members(starting_index, row) : import user from specific index of users and length&lt;br /&gt;
&lt;br /&gt;
=== app/unit/assignment_team.rb ===&lt;br /&gt;
* includes?(participant): check if this assignment team include this participant&lt;br /&gt;
* assign_reviewer(reviewer): assign a reviewer for this assignment team&lt;br /&gt;
* reviewed_by?(reviewer)：check if this assignment team is reviewed by this reviewer&lt;br /&gt;
* topic: get the topic picked up by this team&lt;br /&gt;
* has_submissions?: check if this team submitted work or not&lt;br /&gt;
* reviewed_contributor?(contributor)&lt;br /&gt;
* participants: get all the participants&lt;br /&gt;
* delete: delete the signed up users&lt;br /&gt;
* self.get_first_member(team_id): get the first participant&lt;br /&gt;
* get_hyperlinks&lt;br /&gt;
* get_path&lt;br /&gt;
* get_submitted_files&lt;br /&gt;
* get_review_map_type: return TeamReviewResponseMap&lt;br /&gt;
* self.handle_duplicate(team, name, assignment_id, handle_duplicates): handle duplicate team in different cases&lt;br /&gt;
* self.import(row,session,assignment_id,options): import team members to a exist team or a new team&lt;br /&gt;
* email： get fist team user's email&lt;br /&gt;
* get_participant_type: return AssignmentParticipant&lt;br /&gt;
* get_parent_model：return Assignment&lt;br /&gt;
* fullname&lt;br /&gt;
* get_participants&lt;br /&gt;
* copy(course_id): copy a team from course team&lt;br /&gt;
* add_participant(assignment_id, user): add participant to AssignmentParticipant&lt;br /&gt;
* assignment&lt;br /&gt;
* get_scores(questions): return a hash of scores that the team has received for the questions&lt;br /&gt;
* self.get_team(participant): get this participant's team&lt;br /&gt;
* self.export(csv, parent_id, options): export assignment and team members&lt;br /&gt;
* self.get_export_fields(options)&lt;br /&gt;
* self.create_team_and_node(assignment_id)&lt;br /&gt;
* self.remove_team_by_id(id): Remove a team given the team id&lt;br /&gt;
&lt;br /&gt;
=== app/unit/course_team.rb ===&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
* questions.yml&lt;br /&gt;
* signed_up_users.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
* remove&lt;br /&gt;
** test remove with valid user id&lt;br /&gt;
** test remove with invalid user id&lt;br /&gt;
&lt;br /&gt;
* create&lt;br /&gt;
** test create with valid user id&lt;br /&gt;
** test create with invalid user id&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
** test update with invalid id&lt;br /&gt;
** test update success&lt;br /&gt;
** test update fail (should remain the same)&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
** test edit&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* get participants&lt;br /&gt;
** test get participants&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
** test delete with team node&lt;br /&gt;
** test delete without team node&lt;br /&gt;
&lt;br /&gt;
* get_node_type &lt;br /&gt;
** test get node type&lt;br /&gt;
&lt;br /&gt;
* get_author_name&lt;br /&gt;
** test author name&lt;br /&gt;
&lt;br /&gt;
* generate_team_name() &lt;br /&gt;
** test generate team name from zero&lt;br /&gt;
** test generate team name from one&lt;br /&gt;
&lt;br /&gt;
* get_possible_team_members(name)&lt;br /&gt;
** test get possible team members by exact name&lt;br /&gt;
** test get possible team members by similar name&lt;br /&gt;
** test get possible team members by name in other team&lt;br /&gt;
&lt;br /&gt;
* has_user(user)&lt;br /&gt;
** test has user with valid user&lt;br /&gt;
** test has user with invalid user&lt;br /&gt;
&lt;br /&gt;
* add_member(user, assignment_id)&lt;br /&gt;
** test add member with valid user&lt;br /&gt;
** test add member already in team&lt;br /&gt;
** test add member without assignment id&lt;br /&gt;
** test add member when max team size reached&lt;br /&gt;
&lt;br /&gt;
* copy_members(new_team)&lt;br /&gt;
** test copy members to empty new team&lt;br /&gt;
** test copy members to nonempty new team&lt;br /&gt;
** test copy members with no member in current team&lt;br /&gt;
&lt;br /&gt;
* create_node_object(name, parent_id)&lt;br /&gt;
** ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
&lt;br /&gt;
* check_for_exisiting(parent, name, team_type)&lt;br /&gt;
** test check for exisiting with exisited name&lt;br /&gt;
** test check for exisiting with nonexisted name&lt;br /&gt;
&lt;br /&gt;
* delete_all_by_parent(parent)&lt;br /&gt;
** test delete with valid parents&lt;br /&gt;
** test delete with invalid parents&lt;br /&gt;
&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size)&lt;br /&gt;
** test randomize all by parent with exact number&lt;br /&gt;
** test randomize all by parent without enough people&lt;br /&gt;
** test randomize all by parent with remainder&lt;br /&gt;
&lt;br /&gt;
* generate_team_name(teamnameprefix)&lt;br /&gt;
** test generate prefix team name with valid name&lt;br /&gt;
** test generate prefix team name with duplicated name&lt;br /&gt;
&lt;br /&gt;
* import_team_members(starting_index, row) &lt;br /&gt;
** test import team members with valid index and row&lt;br /&gt;
** test import team members with invalid index and row&lt;br /&gt;
&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* There are two ''def get_participants'', the second one overwritten the first one, so the first one should be deleted.&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/unit/&amp;lt;filename&amp;gt; # for models&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/&amp;lt;filename&amp;gt; # for controllers&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84720</id>
		<title>CSC/ECE 517 Spring 2014/final doc updated qyx</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84720"/>
		<updated>2014-04-24T19:14:50Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: /* app/unit/assignment_team.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
=== assignment_team.rb &amp;amp; course_team.rb ===&lt;br /&gt;
* Both assignment_team class and course_team class are inherited from team class.&lt;br /&gt;
* These two classes have similar methods, which could be used to manage teams for assignment and course more effectively.&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
The “team” object represents a team that consists students who are either participants of course or assignment.&lt;br /&gt;
a team will response to the request on: &lt;br /&gt;
&lt;br /&gt;
* get_participants : get participant in the team&lt;br /&gt;
* delete : delete a team member in the team&lt;br /&gt;
* get_node_type : will return “TeamNode”&lt;br /&gt;
* get_author_name : will return team’s name&lt;br /&gt;
* generate_team_name() : serialize the automatically generated team name (e.g. team 1, team 2, etc.)&lt;br /&gt;
* get_possible_team_members(name) : find a team member by name&lt;br /&gt;
* has_user(user : find a team member by user object&lt;br /&gt;
* add_member(user, assignment_id) : add a user to an assignment team&lt;br /&gt;
* copy_members(new_team) : copy current member in the team to the new team&lt;br /&gt;
* create_node_object(name, parent_id) : ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
* check_for_exisiting(parent, name, team_type) : check if the team name under the same assignment or course is in use.&lt;br /&gt;
* delete_all_by_parent(parent) : delete all teams under the same course/assignment&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size) : randomly assign team members&lt;br /&gt;
* generate_team_name(teamnameprefix) : generate team name with prefix (e.g. prefix_Team1) &lt;br /&gt;
* import_team_members(starting_index, row) : import user from specific index of users and length&lt;br /&gt;
&lt;br /&gt;
=== app/unit/assignment_team.rb ===&lt;br /&gt;
* includes?(participant): check if this assignment team include this participant&lt;br /&gt;
* assign_reviewer(reviewer): assign a reviewer for this assignment team&lt;br /&gt;
* reviewed_by?(reviewer)：check if this assignment team is reviewed by this reviewer&lt;br /&gt;
* topic: get the topic picked up by this team&lt;br /&gt;
* has_submissions?: check if this team submitted work or not&lt;br /&gt;
* reviewed_contributor?(contributor)&lt;br /&gt;
* participants: get all the participants&lt;br /&gt;
* delete: delete the signed up users&lt;br /&gt;
* self.get_first_member(team_id)&lt;br /&gt;
* get_hyperlinks&lt;br /&gt;
* get_path&lt;br /&gt;
* get_submitted_files&lt;br /&gt;
* get_review_map_type&lt;br /&gt;
* self.handle_duplicate(team, name, assignment_id, handle_duplicates)&lt;br /&gt;
* self.import(row,session,assignment_id,options)&lt;br /&gt;
* email&lt;br /&gt;
* get_participant_type&lt;br /&gt;
* get_parent_model&lt;br /&gt;
* fullname&lt;br /&gt;
* get_participants&lt;br /&gt;
* copy(course_id)&lt;br /&gt;
* add_participant(assignment_id, user)&lt;br /&gt;
* assignment&lt;br /&gt;
* get_scores(questions)&lt;br /&gt;
* self.get_team(participant)&lt;br /&gt;
* self.export(csv, parent_id, options)&lt;br /&gt;
* self.get_export_fields(options)&lt;br /&gt;
* self.create_team_and_node(assignment_id)&lt;br /&gt;
* self.remove_team_by_id(id)&lt;br /&gt;
&lt;br /&gt;
=== app/unit/course_team.rb ===&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
* questions.yml&lt;br /&gt;
* signed_up_users.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
* remove&lt;br /&gt;
** test remove with valid user id&lt;br /&gt;
** test remove with invalid user id&lt;br /&gt;
&lt;br /&gt;
* create&lt;br /&gt;
** test create with valid user id&lt;br /&gt;
** test create with invalid user id&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
** test update with invalid id&lt;br /&gt;
** test update success&lt;br /&gt;
** test update fail (should remain the same)&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
** test edit&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* get participants&lt;br /&gt;
** test get participants&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
** test delete with team node&lt;br /&gt;
** test delete without team node&lt;br /&gt;
&lt;br /&gt;
* get_node_type &lt;br /&gt;
** test get node type&lt;br /&gt;
&lt;br /&gt;
* get_author_name&lt;br /&gt;
** test author name&lt;br /&gt;
&lt;br /&gt;
* generate_team_name() &lt;br /&gt;
** test generate team name from zero&lt;br /&gt;
** test generate team name from one&lt;br /&gt;
&lt;br /&gt;
* get_possible_team_members(name)&lt;br /&gt;
** test get possible team members by exact name&lt;br /&gt;
** test get possible team members by similar name&lt;br /&gt;
** test get possible team members by name in other team&lt;br /&gt;
&lt;br /&gt;
* has_user(user)&lt;br /&gt;
** test has user with valid user&lt;br /&gt;
** test has user with invalid user&lt;br /&gt;
&lt;br /&gt;
* add_member(user, assignment_id)&lt;br /&gt;
** test add member with valid user&lt;br /&gt;
** test add member already in team&lt;br /&gt;
** test add member without assignment id&lt;br /&gt;
** test add member when max team size reached&lt;br /&gt;
&lt;br /&gt;
* copy_members(new_team)&lt;br /&gt;
** test copy members to empty new team&lt;br /&gt;
** test copy members to nonempty new team&lt;br /&gt;
** test copy members with no member in current team&lt;br /&gt;
&lt;br /&gt;
* create_node_object(name, parent_id)&lt;br /&gt;
** ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
&lt;br /&gt;
* check_for_exisiting(parent, name, team_type)&lt;br /&gt;
** test check for exisiting with exisited name&lt;br /&gt;
** test check for exisiting with nonexisted name&lt;br /&gt;
&lt;br /&gt;
* delete_all_by_parent(parent)&lt;br /&gt;
** test delete with valid parents&lt;br /&gt;
** test delete with invalid parents&lt;br /&gt;
&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size)&lt;br /&gt;
** test randomize all by parent with exact number&lt;br /&gt;
** test randomize all by parent without enough people&lt;br /&gt;
** test randomize all by parent with remainder&lt;br /&gt;
&lt;br /&gt;
* generate_team_name(teamnameprefix)&lt;br /&gt;
** test generate prefix team name with valid name&lt;br /&gt;
** test generate prefix team name with duplicated name&lt;br /&gt;
&lt;br /&gt;
* import_team_members(starting_index, row) &lt;br /&gt;
** test import team members with valid index and row&lt;br /&gt;
** test import team members with invalid index and row&lt;br /&gt;
&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* There are two ''def get_participants'', the second one overwritten the first one, so the first one should be deleted.&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/unit/&amp;lt;filename&amp;gt; # for models&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/&amp;lt;filename&amp;gt; # for controllers&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84719</id>
		<title>CSC/ECE 517 Spring 2014/final doc updated qyx</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84719"/>
		<updated>2014-04-24T18:59:50Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
=== assignment_team.rb &amp;amp; course_team.rb ===&lt;br /&gt;
* Both assignment_team class and course_team class are inherited from team class.&lt;br /&gt;
* These two classes have similar methods, which could be used to manage teams for assignment and course more effectively.&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
The “team” object represents a team that consists students who are either participants of course or assignment.&lt;br /&gt;
a team will response to the request on: &lt;br /&gt;
&lt;br /&gt;
* get_participants : get participant in the team&lt;br /&gt;
* delete : delete a team member in the team&lt;br /&gt;
* get_node_type : will return “TeamNode”&lt;br /&gt;
* get_author_name : will return team’s name&lt;br /&gt;
* generate_team_name() : serialize the automatically generated team name (e.g. team 1, team 2, etc.)&lt;br /&gt;
* get_possible_team_members(name) : find a team member by name&lt;br /&gt;
* has_user(user : find a team member by user object&lt;br /&gt;
* add_member(user, assignment_id) : add a user to an assignment team&lt;br /&gt;
* copy_members(new_team) : copy current member in the team to the new team&lt;br /&gt;
* create_node_object(name, parent_id) : ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
* check_for_exisiting(parent, name, team_type) : check if the team name under the same assignment or course is in use.&lt;br /&gt;
* delete_all_by_parent(parent) : delete all teams under the same course/assignment&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size) : randomly assign team members&lt;br /&gt;
* generate_team_name(teamnameprefix) : generate team name with prefix (e.g. prefix_Team1) &lt;br /&gt;
* import_team_members(starting_index, row) : import user from specific index of users and length&lt;br /&gt;
&lt;br /&gt;
=== app/unit/assignment_team.rb ===&lt;br /&gt;
&lt;br /&gt;
=== app/unit/course_team.rb ===&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
* questions.yml&lt;br /&gt;
* signed_up_users.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
* remove&lt;br /&gt;
** test remove with valid user id&lt;br /&gt;
** test remove with invalid user id&lt;br /&gt;
&lt;br /&gt;
* create&lt;br /&gt;
** test create with valid user id&lt;br /&gt;
** test create with invalid user id&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
** test update with invalid id&lt;br /&gt;
** test update success&lt;br /&gt;
** test update fail (should remain the same)&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
** test edit&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* get participants&lt;br /&gt;
** test get participants&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
** test delete with team node&lt;br /&gt;
** test delete without team node&lt;br /&gt;
&lt;br /&gt;
* get_node_type &lt;br /&gt;
** test get node type&lt;br /&gt;
&lt;br /&gt;
* get_author_name&lt;br /&gt;
** test author name&lt;br /&gt;
&lt;br /&gt;
* generate_team_name() &lt;br /&gt;
** test generate team name from zero&lt;br /&gt;
** test generate team name from one&lt;br /&gt;
&lt;br /&gt;
* get_possible_team_members(name)&lt;br /&gt;
** test get possible team members by exact name&lt;br /&gt;
** test get possible team members by similar name&lt;br /&gt;
** test get possible team members by name in other team&lt;br /&gt;
&lt;br /&gt;
* has_user(user)&lt;br /&gt;
** test has user with valid user&lt;br /&gt;
** test has user with invalid user&lt;br /&gt;
&lt;br /&gt;
* add_member(user, assignment_id)&lt;br /&gt;
** test add member with valid user&lt;br /&gt;
** test add member already in team&lt;br /&gt;
** test add member without assignment id&lt;br /&gt;
** test add member when max team size reached&lt;br /&gt;
&lt;br /&gt;
* copy_members(new_team)&lt;br /&gt;
** test copy members to empty new team&lt;br /&gt;
** test copy members to nonempty new team&lt;br /&gt;
** test copy members with no member in current team&lt;br /&gt;
&lt;br /&gt;
* create_node_object(name, parent_id)&lt;br /&gt;
** ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
&lt;br /&gt;
* check_for_exisiting(parent, name, team_type)&lt;br /&gt;
** test check for exisiting with exisited name&lt;br /&gt;
** test check for exisiting with nonexisted name&lt;br /&gt;
&lt;br /&gt;
* delete_all_by_parent(parent)&lt;br /&gt;
** test delete with valid parents&lt;br /&gt;
** test delete with invalid parents&lt;br /&gt;
&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size)&lt;br /&gt;
** test randomize all by parent with exact number&lt;br /&gt;
** test randomize all by parent without enough people&lt;br /&gt;
** test randomize all by parent with remainder&lt;br /&gt;
&lt;br /&gt;
* generate_team_name(teamnameprefix)&lt;br /&gt;
** test generate prefix team name with valid name&lt;br /&gt;
** test generate prefix team name with duplicated name&lt;br /&gt;
&lt;br /&gt;
* import_team_members(starting_index, row) &lt;br /&gt;
** test import team members with valid index and row&lt;br /&gt;
** test import team members with invalid index and row&lt;br /&gt;
&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* There are two ''def get_participants'', the second one overwritten the first one, so the first one should be deleted.&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/unit/&amp;lt;filename&amp;gt; # for models&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/&amp;lt;filename&amp;gt; # for controllers&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84718</id>
		<title>CSC/ECE 517 Spring 2014/final doc updated qyx</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84718"/>
		<updated>2014-04-24T18:55:01Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
=== assignment_team.rb &amp;amp; course_team.rb ===&lt;br /&gt;
* Both assignment_team class and course_team class are inherited from team class.&lt;br /&gt;
* These two classes have similar methods, which could be used to manage teams for assignment and course more effectively.&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
The “team” object represents a team that consists students who are either participants of course or assignment.&lt;br /&gt;
a team will response to the request on: &lt;br /&gt;
&lt;br /&gt;
* get_participants : get participant in the team&lt;br /&gt;
* delete : delete a team member in the team&lt;br /&gt;
* get_node_type : will return “TeamNode”&lt;br /&gt;
* get_author_name : will return team’s name&lt;br /&gt;
* generate_team_name() : serialize the automatically generated team name (e.g. team 1, team 2, etc.)&lt;br /&gt;
* get_possible_team_members(name) : find a team member by name&lt;br /&gt;
* has_user(user : find a team member by user object&lt;br /&gt;
* add_member(user, assignment_id) : add a user to an assignment team&lt;br /&gt;
* copy_members(new_team) : copy current member in the team to the new team&lt;br /&gt;
* create_node_object(name, parent_id) : ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
* check_for_exisiting(parent, name, team_type) : check if the team name under the same assignment or course is in use.&lt;br /&gt;
* delete_all_by_parent(parent) : delete all teams under the same course/assignment&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size) : randomly assign team members&lt;br /&gt;
* generate_team_name(teamnameprefix) : generate team name with prefix (e.g. prefix_Team1) &lt;br /&gt;
* import_team_members(starting_index, row) : import user from specific index of users and length&lt;br /&gt;
&lt;br /&gt;
=== app/unit/assignment_team.rb ===&lt;br /&gt;
&lt;br /&gt;
=== app/unit/course_team.rb ===&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
* remove&lt;br /&gt;
** test remove with valid user id&lt;br /&gt;
** test remove with invalid user id&lt;br /&gt;
&lt;br /&gt;
* create&lt;br /&gt;
** test create with valid user id&lt;br /&gt;
** test create with invalid user id&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
** test update with invalid id&lt;br /&gt;
** test update success&lt;br /&gt;
** test update fail (should remain the same)&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
** test edit&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* get participants&lt;br /&gt;
** test get participants&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
** test delete with team node&lt;br /&gt;
** test delete without team node&lt;br /&gt;
&lt;br /&gt;
* get_node_type &lt;br /&gt;
** test get node type&lt;br /&gt;
&lt;br /&gt;
* get_author_name&lt;br /&gt;
** test author name&lt;br /&gt;
&lt;br /&gt;
* generate_team_name() &lt;br /&gt;
** test generate team name from zero&lt;br /&gt;
** test generate team name from one&lt;br /&gt;
&lt;br /&gt;
* get_possible_team_members(name)&lt;br /&gt;
** test get possible team members by exact name&lt;br /&gt;
** test get possible team members by similar name&lt;br /&gt;
** test get possible team members by name in other team&lt;br /&gt;
&lt;br /&gt;
* has_user(user)&lt;br /&gt;
** test has user with valid user&lt;br /&gt;
** test has user with invalid user&lt;br /&gt;
&lt;br /&gt;
* add_member(user, assignment_id)&lt;br /&gt;
** test add member with valid user&lt;br /&gt;
** test add member already in team&lt;br /&gt;
** test add member without assignment id&lt;br /&gt;
** test add member when max team size reached&lt;br /&gt;
&lt;br /&gt;
* copy_members(new_team)&lt;br /&gt;
** test copy members to empty new team&lt;br /&gt;
** test copy members to nonempty new team&lt;br /&gt;
** test copy members with no member in current team&lt;br /&gt;
&lt;br /&gt;
* create_node_object(name, parent_id)&lt;br /&gt;
** ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
&lt;br /&gt;
* check_for_exisiting(parent, name, team_type)&lt;br /&gt;
** test check for exisiting with exisited name&lt;br /&gt;
** test check for exisiting with nonexisted name&lt;br /&gt;
&lt;br /&gt;
* delete_all_by_parent(parent)&lt;br /&gt;
** test delete with valid parents&lt;br /&gt;
** test delete with invalid parents&lt;br /&gt;
&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size)&lt;br /&gt;
** test randomize all by parent with exact number&lt;br /&gt;
** test randomize all by parent without enough people&lt;br /&gt;
** test randomize all by parent with remainder&lt;br /&gt;
&lt;br /&gt;
* generate_team_name(teamnameprefix)&lt;br /&gt;
** test generate prefix team name with valid name&lt;br /&gt;
** test generate prefix team name with duplicated name&lt;br /&gt;
&lt;br /&gt;
* import_team_members(starting_index, row) &lt;br /&gt;
** test import team members with valid index and row&lt;br /&gt;
** test import team members with invalid index and row&lt;br /&gt;
&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* There are two ''def get_participants'', the second one overwritten the first one, so the first one should be deleted.&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/unit/&amp;lt;filename&amp;gt; # for models&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/&amp;lt;filename&amp;gt; # for controllers&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84717</id>
		<title>CSC/ECE 517 Spring 2014/final doc updated qyx</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84717"/>
		<updated>2014-04-24T18:51:34Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
=== assignment_team.rb &amp;amp; course_team.rb ===&lt;br /&gt;
* Both assignment_team class and course_team class are inherited from team class.&lt;br /&gt;
* These two classes have similar methods, which could be used to manage teams for assignment and course more effectively.&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
The “team” object represents a team that consists students who are either participants of course or assignment.&lt;br /&gt;
a team will response to the request on: &lt;br /&gt;
&lt;br /&gt;
;get_participants : get participant in the team&lt;br /&gt;
;delete : delete a team member in the team&lt;br /&gt;
;get_node_type : will return “TeamNode”&lt;br /&gt;
;get_author_name : will return team’s name&lt;br /&gt;
;generate_team_name() : serialize the automatically generated team name (e.g. team 1, team 2, etc.)&lt;br /&gt;
;get_possible_team_members(name) : find a team member by name&lt;br /&gt;
;has_user(user : find a team member by user object&lt;br /&gt;
;add_member(user, assignment_id) : add a user to an assignment team&lt;br /&gt;
;copy_members(new_team) : copy current member in the team to the new team&lt;br /&gt;
;create_node_object(name, parent_id) : ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
;check_for_exisiting(parent, name, team_type) : check if the team name under the same assignment or course is in use.&lt;br /&gt;
;Delete_all_by_parent(parent) : delete all teams under the same course/assignment&lt;br /&gt;
;Randomize_all_by_parent(parent, team_type, team_size) : randomly assign team members&lt;br /&gt;
;generate_team_name(teamnameprefix) : generate team name with prefix (e.g. prefix_Team1) &lt;br /&gt;
;import_team_members(starting_index, row) : import user from specific index of users and length&lt;br /&gt;
&lt;br /&gt;
=== app/unit/assignment_team.rb ===&lt;br /&gt;
&lt;br /&gt;
=== app/unit/course_team.rb ===&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
* remove&lt;br /&gt;
** test remove with valid user id&lt;br /&gt;
** test remove with invalid user id&lt;br /&gt;
&lt;br /&gt;
* create&lt;br /&gt;
** test create with valid user id&lt;br /&gt;
** test create with invalid user id&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
** test update with invalid id&lt;br /&gt;
** test update success&lt;br /&gt;
** test update fail (should remain the same)&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
** test edit&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* get participants&lt;br /&gt;
** test get participants&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
** test delete with team node&lt;br /&gt;
** test delete without team node&lt;br /&gt;
&lt;br /&gt;
* get_node_type &lt;br /&gt;
** test get node type&lt;br /&gt;
&lt;br /&gt;
* get_author_name&lt;br /&gt;
** test author name&lt;br /&gt;
&lt;br /&gt;
* generate_team_name() &lt;br /&gt;
** test generate team name from zero&lt;br /&gt;
** test generate team name from one&lt;br /&gt;
&lt;br /&gt;
* get_possible_team_members(name)&lt;br /&gt;
** test get possible team members by exact name&lt;br /&gt;
** test get possible team members by similar name&lt;br /&gt;
** test get possible team members by name in other team&lt;br /&gt;
&lt;br /&gt;
* has_user(user)&lt;br /&gt;
** test has user with valid user&lt;br /&gt;
** test has user with invalid user&lt;br /&gt;
&lt;br /&gt;
* add_member(user, assignment_id)&lt;br /&gt;
** test add member with valid user&lt;br /&gt;
** test add member already in team&lt;br /&gt;
** test add member without assignment id&lt;br /&gt;
** test add member when max team size reached&lt;br /&gt;
&lt;br /&gt;
* copy_members(new_team)&lt;br /&gt;
** test copy members to empty new team&lt;br /&gt;
** test copy members to nonempty new team&lt;br /&gt;
** test copy members with no member in current team&lt;br /&gt;
&lt;br /&gt;
* create_node_object(name, parent_id)&lt;br /&gt;
** ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
&lt;br /&gt;
* check_for_exisiting(parent, name, team_type)&lt;br /&gt;
** test check for exisiting with exisited name&lt;br /&gt;
** test check for exisiting with nonexisted name&lt;br /&gt;
&lt;br /&gt;
* delete_all_by_parent(parent)&lt;br /&gt;
** test delete with valid parents&lt;br /&gt;
** test delete with invalid parents&lt;br /&gt;
&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size)&lt;br /&gt;
** test randomize all by parent with exact number&lt;br /&gt;
** test randomize all by parent without enough people&lt;br /&gt;
** test randomize all by parent with remainder&lt;br /&gt;
&lt;br /&gt;
* generate_team_name(teamnameprefix)&lt;br /&gt;
** test generate prefix team name with valid name&lt;br /&gt;
** test generate prefix team name with duplicated name&lt;br /&gt;
&lt;br /&gt;
* import_team_members(starting_index, row) &lt;br /&gt;
** test import team members with valid index and row&lt;br /&gt;
** test import team members with invalid index and row&lt;br /&gt;
&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* There are two ''def get_participants'', the second one overwritten the first one, so the first one should be deleted.&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/unit/&amp;lt;filename&amp;gt; # for models&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/&amp;lt;filename&amp;gt; # for controllers&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84716</id>
		<title>CSC/ECE 517 Spring 2014/final doc updated qyx</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/final_doc_updated_qyx&amp;diff=84716"/>
		<updated>2014-04-24T18:40:37Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: Created page with &amp;quot;=E1414: Testing classes related to teams= ''Please be advised that we do not have deployment link, since our work are all back-end tests'' __TOC__ == Introduction == This project...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participant_controller.rb===&lt;br /&gt;
* teams_participant.rb and teams_participant_controller.rb are used to manage the participants of teams.&lt;br /&gt;
* There is no functional test for teams_participant_controller.rb and unit test for teams_participant.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_participant.rb===&lt;br /&gt;
The teams_participant.rb is a model belonging to both users and teams. It is used when a team participant is created, listed or deleted.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_participant_controller.rb===&lt;br /&gt;
The teams_participant_controller support team participants management so the team participant:&lt;br /&gt;
* get a participant name by inputting part of the name&lt;br /&gt;
* list team participants of a team &lt;br /&gt;
* add a participant to a team&lt;br /&gt;
* remove a selected team participant from a team&lt;br /&gt;
* remove all team participants belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
The “team” object represents a team that consists students who are either participants of course or assignment.&lt;br /&gt;
a team will response to the request on: &lt;br /&gt;
&lt;br /&gt;
;get_participants : get participant in the team&lt;br /&gt;
;delete : delete a team member in the team&lt;br /&gt;
;get_node_type : will return “TeamNode”&lt;br /&gt;
;get_author_name : will return team’s name&lt;br /&gt;
;generate_team_name() : serialize the automatically generated team name (e.g. team 1, team 2, etc.)&lt;br /&gt;
;get_possible_team_members(name) : find a team member by name&lt;br /&gt;
;has_user(user : find a team member by user object&lt;br /&gt;
;add_member(user, assignment_id) : add a user to an assignment team&lt;br /&gt;
;copy_members(new_team) : copy current member in the team to the new team&lt;br /&gt;
;create_node_object(name, parent_id) : ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
;check_for_exisiting(parent, name, team_type) : check if the team name under the same assignment or course is in use.&lt;br /&gt;
;Delete_all_by_parent(parent) : delete all teams under the same course/assignment&lt;br /&gt;
;Randomize_all_by_parent(parent, team_type, team_size) : randomly assign team members&lt;br /&gt;
;generate_team_name(teamnameprefix) : generate team name with prefix (e.g. prefix_Team1) &lt;br /&gt;
;import_team_members(starting_index, row) : import user from specific index of users and length&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participant_controller.rb ===&lt;br /&gt;
Besides the above fixtures, we also need the following fixrure&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
&lt;br /&gt;
=== teams.rb ===&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== teams_participant_controller.rb ===&lt;br /&gt;
[[File:New.jpg]]&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== teams_participant.rb ===&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
** Test delete to check if team node and the team user decreases by one&lt;br /&gt;
&lt;br /&gt;
=== teams_participant_controller.rb ===&lt;br /&gt;
* auto_complete_for_user_name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
* list&lt;br /&gt;
** Test list with invalid team id&lt;br /&gt;
* new&lt;br /&gt;
** Test new with invalid team id&lt;br /&gt;
* create&lt;br /&gt;
** Test create with invalid team id&lt;br /&gt;
** Test create to check if the number of participant increases by one&lt;br /&gt;
** Test create with invalid user id and maximum member number is not reached&lt;br /&gt;
** Test create with valid user id and maximum member number is reached&lt;br /&gt;
** Test create with invalid user id and maximum member number is not reached&lt;br /&gt;
* delete&lt;br /&gt;
** Test delete with invalid id&lt;br /&gt;
** Test delete to check the number of participant decreases&lt;br /&gt;
* delete_select&lt;br /&gt;
** Test delete_select with invalid item id&lt;br /&gt;
** Test delete_select to check if the number of participant decreases by one&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
* remove&lt;br /&gt;
** test remove with valid user id&lt;br /&gt;
** test remove with invalid user id&lt;br /&gt;
&lt;br /&gt;
* create&lt;br /&gt;
** test create with valid user id&lt;br /&gt;
** test create with invalid user id&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
** test update with invalid id&lt;br /&gt;
** test update success&lt;br /&gt;
** test update fail (should remain the same)&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
** test edit&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* get participants&lt;br /&gt;
** test get participants&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
** test delete with team node&lt;br /&gt;
** test delete without team node&lt;br /&gt;
&lt;br /&gt;
* get_node_type &lt;br /&gt;
** test get node type&lt;br /&gt;
&lt;br /&gt;
* get_author_name&lt;br /&gt;
** test author name&lt;br /&gt;
&lt;br /&gt;
* generate_team_name() &lt;br /&gt;
** test generate team name from zero&lt;br /&gt;
** test generate team name from one&lt;br /&gt;
&lt;br /&gt;
* get_possible_team_members(name)&lt;br /&gt;
** test get possible team members by exact name&lt;br /&gt;
** test get possible team members by similar name&lt;br /&gt;
** test get possible team members by name in other team&lt;br /&gt;
&lt;br /&gt;
* has_user(user)&lt;br /&gt;
** test has user with valid user&lt;br /&gt;
** test has user with invalid user&lt;br /&gt;
&lt;br /&gt;
* add_member(user, assignment_id)&lt;br /&gt;
** test add member with valid user&lt;br /&gt;
** test add member already in team&lt;br /&gt;
** test add member without assignment id&lt;br /&gt;
** test add member when max team size reached&lt;br /&gt;
&lt;br /&gt;
* copy_members(new_team)&lt;br /&gt;
** test copy members to empty new team&lt;br /&gt;
** test copy members to nonempty new team&lt;br /&gt;
** test copy members with no member in current team&lt;br /&gt;
&lt;br /&gt;
* create_node_object(name, parent_id)&lt;br /&gt;
** ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
&lt;br /&gt;
* check_for_exisiting(parent, name, team_type)&lt;br /&gt;
** test check for exisiting with exisited name&lt;br /&gt;
** test check for exisiting with nonexisted name&lt;br /&gt;
&lt;br /&gt;
* delete_all_by_parent(parent)&lt;br /&gt;
** test delete with valid parents&lt;br /&gt;
** test delete with invalid parents&lt;br /&gt;
&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size)&lt;br /&gt;
** test randomize all by parent with exact number&lt;br /&gt;
** test randomize all by parent without enough people&lt;br /&gt;
** test randomize all by parent with remainder&lt;br /&gt;
&lt;br /&gt;
* generate_team_name(teamnameprefix)&lt;br /&gt;
** test generate prefix team name with valid name&lt;br /&gt;
** test generate prefix team name with duplicated name&lt;br /&gt;
&lt;br /&gt;
* import_team_members(starting_index, row) &lt;br /&gt;
** test import team members with valid index and row&lt;br /&gt;
** test import team members with invalid index and row&lt;br /&gt;
&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* There are two ''def get_participants'', the second one overwritten the first one, so the first one should be deleted.&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/unit/&amp;lt;filename&amp;gt; # for models&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/&amp;lt;filename&amp;gt; # for controllers&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014&amp;diff=84715</id>
		<title>CSC/ECE 517 Spring 2014</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014&amp;diff=84715"/>
		<updated>2014-04-24T18:39:09Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;*[[CSC/ECE_517_Fall_2012/example_page]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2014/ch1a 1a rt]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2014/ch1a 1e rm]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2014/ch1 1w1h jg ]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2014/ch1 1w1b np]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2014/ch1 1w1f mj]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2014/ch1a 1d mm]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2014/ch1a 1c yj]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2014/ch1 1w1l m]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2014/ch1 1w1m bm]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2014/ch1a 1p fy]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2014/oss E1401 lmn]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2014/oss E1402 mmb]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2014/oss E1404 mnp]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2014/oss E1405 irw]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2014/oss E1406 st]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2014/oss S1402 jyy]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2014/oss E1413 mnp]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2014/oss E1414 st]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2014/security_audit]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2014/final_doc_updated qyx]]&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84382</id>
		<title>CSC/ECE 517 Spring 2014/oss E1414 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84382"/>
		<updated>2014-04-10T00:41:54Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: /* teams_participant.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participant_controller.rb===&lt;br /&gt;
* teams_participant.rb and teams_participant_controller.rb are used to manage the participants of teams.&lt;br /&gt;
* There is no functional test for teams_participant_controller.rb and unit test for teams_participant.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_participant.rb===&lt;br /&gt;
The teams_participant.rb is a model belonging to both users and teams. It is used when a team participant is created, listed or deleted.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_participant_controller.rb===&lt;br /&gt;
The teams_participant_controller support team participants management so the team participant:&lt;br /&gt;
* get a participant name by inputting part of the name&lt;br /&gt;
* list team participants of a team &lt;br /&gt;
* add a participant to a team&lt;br /&gt;
* remove a selected team participant from a team&lt;br /&gt;
* remove all team participants belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
The “team” object represents a team that consists students who are either participants of course or assignment.&lt;br /&gt;
a team will response to the request on: &lt;br /&gt;
&lt;br /&gt;
;get_participants : get participant in the team&lt;br /&gt;
;delete : delete a team member in the team&lt;br /&gt;
;get_node_type : will return “TeamNode”&lt;br /&gt;
;get_author_name : will return team’s name&lt;br /&gt;
;generate_team_name() : serialize the automatically generated team name (e.g. team 1, team 2, etc.)&lt;br /&gt;
;get_possible_team_members(name) : find a team member by name&lt;br /&gt;
;has_user(user : find a team member by user object&lt;br /&gt;
;add_member(user, assignment_id) : add a user to an assignment team&lt;br /&gt;
;copy_members(new_team) : copy current member in the team to the new team&lt;br /&gt;
;create_node_object(name, parent_id) : ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
;check_for_exisiting(parent, name, team_type) : check if the team name under the same assignment or course is in use.&lt;br /&gt;
;Delete_all_by_parent(parent) : delete all teams under the same course/assignment&lt;br /&gt;
;Randomize_all_by_parent(parent, team_type, team_size) : randomly assign team members&lt;br /&gt;
;generate_team_name(teamnameprefix) : generate team name with prefix (e.g. prefix_Team1) &lt;br /&gt;
;import_team_members(starting_index, row) : import user from specific index of users and length&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participant_controller.rb ===&lt;br /&gt;
Besides the above fixtures, we also need the following fixrure&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
&lt;br /&gt;
=== teams.rb ===&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== teams_participant_controller.rb ===&lt;br /&gt;
[[File:New.jpg]]&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== teams_participant.rb ===&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
** Test delete to check if team node and the team user decreases by one&lt;br /&gt;
&lt;br /&gt;
=== teams_participant_controller.rb ===&lt;br /&gt;
* auto_complete_for_user_name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
* list&lt;br /&gt;
** Test list with invalid team id&lt;br /&gt;
* new&lt;br /&gt;
** Test new with invalid team id&lt;br /&gt;
* create&lt;br /&gt;
** Test create with invalid team id&lt;br /&gt;
** Test create to check if the number of participant increases by one&lt;br /&gt;
** Test create with invalid user id and maximum member number is not reached&lt;br /&gt;
** Test create with valid user id and maximum member number is reached&lt;br /&gt;
** Test create with invalid user id and maximum member number is not reached&lt;br /&gt;
* delete&lt;br /&gt;
** Test delete with invalid id&lt;br /&gt;
** Test delete to check the number of participant decreases&lt;br /&gt;
* delete_select&lt;br /&gt;
** Test delete_select with invalid item id&lt;br /&gt;
** Test delete_select to check if the number of participant decreases by one&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
* remove&lt;br /&gt;
** test remove with valid user id&lt;br /&gt;
** test remove with invalid user id&lt;br /&gt;
&lt;br /&gt;
* create&lt;br /&gt;
** test create with valid user id&lt;br /&gt;
** test create with invalid user id&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
** test update with invalid id&lt;br /&gt;
** test update success&lt;br /&gt;
** test update fail (should remain the same)&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
** test edit&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* get participants&lt;br /&gt;
** test get participants&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
** test delete with team node&lt;br /&gt;
** test delete without team node&lt;br /&gt;
&lt;br /&gt;
* get_node_type &lt;br /&gt;
** test get node type&lt;br /&gt;
&lt;br /&gt;
* get_author_name&lt;br /&gt;
** test author name&lt;br /&gt;
&lt;br /&gt;
* generate_team_name() &lt;br /&gt;
** test generate team name from zero&lt;br /&gt;
** test generate team name from one&lt;br /&gt;
&lt;br /&gt;
* get_possible_team_members(name)&lt;br /&gt;
** test get possible team members by exact name&lt;br /&gt;
** test get possible team members by similar name&lt;br /&gt;
** test get possible team members by name in other team&lt;br /&gt;
&lt;br /&gt;
* has_user(user)&lt;br /&gt;
** test has user with valid user&lt;br /&gt;
** test has user with invalid user&lt;br /&gt;
&lt;br /&gt;
* add_member(user, assignment_id)&lt;br /&gt;
** test add member with valid user&lt;br /&gt;
** test add member already in team&lt;br /&gt;
** test add member without assignment id&lt;br /&gt;
** test add member when max team size reached&lt;br /&gt;
&lt;br /&gt;
* copy_members(new_team)&lt;br /&gt;
** test copy members to empty new team&lt;br /&gt;
** test copy members to nonempty new team&lt;br /&gt;
** test copy members with no member in current team&lt;br /&gt;
&lt;br /&gt;
* create_node_object(name, parent_id)&lt;br /&gt;
** ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
&lt;br /&gt;
* check_for_exisiting(parent, name, team_type)&lt;br /&gt;
** test check for exisiting with exisited name&lt;br /&gt;
** test check for exisiting with nonexisted name&lt;br /&gt;
&lt;br /&gt;
* delete_all_by_parent(parent)&lt;br /&gt;
** test delete with valid parents&lt;br /&gt;
** test delete with invalid parents&lt;br /&gt;
&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size)&lt;br /&gt;
** test randomize all by parent with exact number&lt;br /&gt;
** test randomize all by parent without enough people&lt;br /&gt;
** test randomize all by parent with remainder&lt;br /&gt;
&lt;br /&gt;
* generate_team_name(teamnameprefix)&lt;br /&gt;
** test generate prefix team name with valid name&lt;br /&gt;
** test generate prefix team name with duplicated name&lt;br /&gt;
&lt;br /&gt;
* import_team_members(starting_index, row) &lt;br /&gt;
** test import team members with valid index and row&lt;br /&gt;
** test import team members with invalid index and row&lt;br /&gt;
&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* There are two ''def get_participants'', the second one overwritten the first one, so the first one should be deleted.&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/unit/&amp;lt;filename&amp;gt; # for models&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/&amp;lt;filename&amp;gt; # for controllers&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84381</id>
		<title>CSC/ECE 517 Spring 2014/oss E1414 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84381"/>
		<updated>2014-04-10T00:41:17Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participant_controller.rb===&lt;br /&gt;
* teams_participant.rb and teams_participant_controller.rb are used to manage the participants of teams.&lt;br /&gt;
* There is no functional test for teams_participant_controller.rb and unit test for teams_participant.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_participant.rb===&lt;br /&gt;
The teams_participant.rb is a model belonging to both users and teams. It is used when a team participant is created, listed or deleted.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_participant_controller.rb===&lt;br /&gt;
The teams_participant_controller support team participants management so the team participant:&lt;br /&gt;
* get a participant name by inputting part of the name&lt;br /&gt;
* list team participants of a team &lt;br /&gt;
* add a participant to a team&lt;br /&gt;
* remove a selected team participant from a team&lt;br /&gt;
* remove all team participants belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
The “team” object represents a team that consists students who are either participants of course or assignment.&lt;br /&gt;
a team will response to the request on: &lt;br /&gt;
&lt;br /&gt;
;get_participants : get participant in the team&lt;br /&gt;
;delete : delete a team member in the team&lt;br /&gt;
;get_node_type : will return “TeamNode”&lt;br /&gt;
;get_author_name : will return team’s name&lt;br /&gt;
;generate_team_name() : serialize the automatically generated team name (e.g. team 1, team 2, etc.)&lt;br /&gt;
;get_possible_team_members(name) : find a team member by name&lt;br /&gt;
;has_user(user : find a team member by user object&lt;br /&gt;
;add_member(user, assignment_id) : add a user to an assignment team&lt;br /&gt;
;copy_members(new_team) : copy current member in the team to the new team&lt;br /&gt;
;create_node_object(name, parent_id) : ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
;check_for_exisiting(parent, name, team_type) : check if the team name under the same assignment or course is in use.&lt;br /&gt;
;Delete_all_by_parent(parent) : delete all teams under the same course/assignment&lt;br /&gt;
;Randomize_all_by_parent(parent, team_type, team_size) : randomly assign team members&lt;br /&gt;
;generate_team_name(teamnameprefix) : generate team name with prefix (e.g. prefix_Team1) &lt;br /&gt;
;import_team_members(starting_index, row) : import user from specific index of users and length&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participant_controller.rb ===&lt;br /&gt;
Besides the above fixtures, we also need the following fixrure&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
&lt;br /&gt;
=== teams.rb ===&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== teams_participant_controller.rb ===&lt;br /&gt;
[[File:New.jpg]]&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== teams_participant.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if team node and the team user decreases by one&lt;br /&gt;
&lt;br /&gt;
=== teams_participant_controller.rb ===&lt;br /&gt;
* auto_complete_for_user_name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
* list&lt;br /&gt;
** Test list with invalid team id&lt;br /&gt;
* new&lt;br /&gt;
** Test new with invalid team id&lt;br /&gt;
* create&lt;br /&gt;
** Test create with invalid team id&lt;br /&gt;
** Test create to check if the number of participant increases by one&lt;br /&gt;
** Test create with invalid user id and maximum member number is not reached&lt;br /&gt;
** Test create with valid user id and maximum member number is reached&lt;br /&gt;
** Test create with invalid user id and maximum member number is not reached&lt;br /&gt;
* delete&lt;br /&gt;
** Test delete with invalid id&lt;br /&gt;
** Test delete to check the number of participant decreases&lt;br /&gt;
* delete_select&lt;br /&gt;
** Test delete_select with invalid item id&lt;br /&gt;
** Test delete_select to check if the number of participant decreases by one&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
* remove&lt;br /&gt;
** test remove with valid user id&lt;br /&gt;
** test remove with invalid user id&lt;br /&gt;
&lt;br /&gt;
* create&lt;br /&gt;
** test create with valid user id&lt;br /&gt;
** test create with invalid user id&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
** test update with invalid id&lt;br /&gt;
** test update success&lt;br /&gt;
** test update fail (should remain the same)&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
** test edit&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* get participants&lt;br /&gt;
** test get participants&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
** test delete with team node&lt;br /&gt;
** test delete without team node&lt;br /&gt;
&lt;br /&gt;
* get_node_type &lt;br /&gt;
** test get node type&lt;br /&gt;
&lt;br /&gt;
* get_author_name&lt;br /&gt;
** test author name&lt;br /&gt;
&lt;br /&gt;
* generate_team_name() &lt;br /&gt;
** test generate team name from zero&lt;br /&gt;
** test generate team name from one&lt;br /&gt;
&lt;br /&gt;
* get_possible_team_members(name)&lt;br /&gt;
** test get possible team members by exact name&lt;br /&gt;
** test get possible team members by similar name&lt;br /&gt;
** test get possible team members by name in other team&lt;br /&gt;
&lt;br /&gt;
* has_user(user)&lt;br /&gt;
** test has user with valid user&lt;br /&gt;
** test has user with invalid user&lt;br /&gt;
&lt;br /&gt;
* add_member(user, assignment_id)&lt;br /&gt;
** test add member with valid user&lt;br /&gt;
** test add member already in team&lt;br /&gt;
** test add member without assignment id&lt;br /&gt;
** test add member when max team size reached&lt;br /&gt;
&lt;br /&gt;
* copy_members(new_team)&lt;br /&gt;
** test copy members to empty new team&lt;br /&gt;
** test copy members to nonempty new team&lt;br /&gt;
** test copy members with no member in current team&lt;br /&gt;
&lt;br /&gt;
* create_node_object(name, parent_id)&lt;br /&gt;
** ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
&lt;br /&gt;
* check_for_exisiting(parent, name, team_type)&lt;br /&gt;
** test check for exisiting with exisited name&lt;br /&gt;
** test check for exisiting with nonexisted name&lt;br /&gt;
&lt;br /&gt;
* delete_all_by_parent(parent)&lt;br /&gt;
** test delete with valid parents&lt;br /&gt;
** test delete with invalid parents&lt;br /&gt;
&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size)&lt;br /&gt;
** test randomize all by parent with exact number&lt;br /&gt;
** test randomize all by parent without enough people&lt;br /&gt;
** test randomize all by parent with remainder&lt;br /&gt;
&lt;br /&gt;
* generate_team_name(teamnameprefix)&lt;br /&gt;
** test generate prefix team name with valid name&lt;br /&gt;
** test generate prefix team name with duplicated name&lt;br /&gt;
&lt;br /&gt;
* import_team_members(starting_index, row) &lt;br /&gt;
** test import team members with valid index and row&lt;br /&gt;
** test import team members with invalid index and row&lt;br /&gt;
&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* There are two ''def get_participants'', the second one overwritten the first one, so the first one should be deleted.&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/unit/&amp;lt;filename&amp;gt; # for models&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/&amp;lt;filename&amp;gt; # for controllers&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84377</id>
		<title>CSC/ECE 517 Spring 2014/oss E1414 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84377"/>
		<updated>2014-04-10T00:38:17Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: /* teams_participant.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participant_controller.rb===&lt;br /&gt;
* teams_participant.rb and teams_participant_controller.rb are used to manage the participants of teams.&lt;br /&gt;
* There is no functional test for teams_participant_controller.rb and unit test for teams_participant.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_participant.rb===&lt;br /&gt;
The teams_participant.rb is a model belonging to both users and teams. It is used when a team participant is created, listed or deleted.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_participant_controller.rb===&lt;br /&gt;
The teams_participant_controller support team participants management so the team participant:&lt;br /&gt;
* get a participant name by inputting part of the name&lt;br /&gt;
* list team participants of a team &lt;br /&gt;
* add a participant to a team&lt;br /&gt;
* remove a selected team participant from a team&lt;br /&gt;
* remove all team participants belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
The “team” object represents a team that consists students who are either participants of course or assignment.&lt;br /&gt;
a team will response to the request on: &lt;br /&gt;
&lt;br /&gt;
;get_participants : get participant in the team&lt;br /&gt;
;delete : delete a team member in the team&lt;br /&gt;
;get_node_type : will return “TeamNode”&lt;br /&gt;
;get_author_name : will return team’s name&lt;br /&gt;
;generate_team_name() : serialize the automatically generated team name (e.g. team 1, team 2, etc.)&lt;br /&gt;
;get_possible_team_members(name) : find a team member by name&lt;br /&gt;
;has_user(user : find a team member by user object&lt;br /&gt;
;add_member(user, assignment_id) : add a user to an assignment team&lt;br /&gt;
;copy_members(new_team) : copy current member in the team to the new team&lt;br /&gt;
;create_node_object(name, parent_id) : ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
;check_for_exisiting(parent, name, team_type) : check if the team name under the same assignment or course is in use.&lt;br /&gt;
;Delete_all_by_parent(parent) : delete all teams under the same course/assignment&lt;br /&gt;
;Randomize_all_by_parent(parent, team_type, team_size) : randomly assign team members&lt;br /&gt;
;generate_team_name(teamnameprefix) : generate team name with prefix (e.g. prefix_Team1) &lt;br /&gt;
;import_team_members(starting_index, row) : import user from specific index of users and length&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participant_controller.rb ===&lt;br /&gt;
Besides the above fixtures, we also need the following fixrure&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
&lt;br /&gt;
=== teams.rb ===&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== teams_participant_controller.rb ===&lt;br /&gt;
[[File:New.jpg]]&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== teams_participant.rb ===&lt;br /&gt;
&lt;br /&gt;
* Test Delete to check if team node and the team user decreases by one&lt;br /&gt;
&lt;br /&gt;
=== teams_participant_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
** Test Create to check if the number of participant increases by one&lt;br /&gt;
** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
** Test Delete_select to check if the number of participant decreases by one&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
* remove&lt;br /&gt;
** test remove with valid user id&lt;br /&gt;
** test remove with invalid user id&lt;br /&gt;
&lt;br /&gt;
* create&lt;br /&gt;
** test create with valid user id&lt;br /&gt;
** test create with invalid user id&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
** test update with invalid id&lt;br /&gt;
** test update success&lt;br /&gt;
** test update fail (should remain the same)&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
** test edit&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* get participants&lt;br /&gt;
** test get participants&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
** test delete with team node&lt;br /&gt;
** test delete without team node&lt;br /&gt;
&lt;br /&gt;
* get_node_type &lt;br /&gt;
** test get node type&lt;br /&gt;
&lt;br /&gt;
* get_author_name&lt;br /&gt;
** test author name&lt;br /&gt;
&lt;br /&gt;
* generate_team_name() &lt;br /&gt;
** test generate team name from zero&lt;br /&gt;
** test generate team name from one&lt;br /&gt;
&lt;br /&gt;
* get_possible_team_members(name)&lt;br /&gt;
** test get possible team members by exact name&lt;br /&gt;
** test get possible team members by similar name&lt;br /&gt;
** test get possible team members by name in other team&lt;br /&gt;
&lt;br /&gt;
* has_user(user)&lt;br /&gt;
** test has user with valid user&lt;br /&gt;
** test has user with invalid user&lt;br /&gt;
&lt;br /&gt;
* add_member(user, assignment_id)&lt;br /&gt;
** test add member with valid user&lt;br /&gt;
** test add member already in team&lt;br /&gt;
** test add member without assignment id&lt;br /&gt;
** test add member when max team size reached&lt;br /&gt;
&lt;br /&gt;
* copy_members(new_team)&lt;br /&gt;
** test copy members to empty new team&lt;br /&gt;
** test copy members to nonempty new team&lt;br /&gt;
** test copy members with no member in current team&lt;br /&gt;
&lt;br /&gt;
* create_node_object(name, parent_id)&lt;br /&gt;
** ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
&lt;br /&gt;
* check_for_exisiting(parent, name, team_type)&lt;br /&gt;
** test check for exisiting with exisited name&lt;br /&gt;
** test check for exisiting with nonexisted name&lt;br /&gt;
&lt;br /&gt;
* delete_all_by_parent(parent)&lt;br /&gt;
** test delete with valid parents&lt;br /&gt;
** test delete with invalid parents&lt;br /&gt;
&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size)&lt;br /&gt;
** test randomize all by parent with exact number&lt;br /&gt;
** test randomize all by parent without enough people&lt;br /&gt;
** test randomize all by parent with remainder&lt;br /&gt;
&lt;br /&gt;
* generate_team_name(teamnameprefix)&lt;br /&gt;
** test generate prefix team name with valid name&lt;br /&gt;
** test generate prefix team name with duplicated name&lt;br /&gt;
&lt;br /&gt;
* import_team_members(starting_index, row) &lt;br /&gt;
** test import team members with valid index and row&lt;br /&gt;
** test import team members with invalid index and row&lt;br /&gt;
&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* There are two ''def get_participants'', the second one overwritten the first one, so the first one should be deleted.&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/unit/&amp;lt;filename&amp;gt; # for models&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/&amp;lt;filename&amp;gt; # for controllers&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84376</id>
		<title>CSC/ECE 517 Spring 2014/oss E1414 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84376"/>
		<updated>2014-04-10T00:37:01Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participant_controller.rb===&lt;br /&gt;
* teams_participant.rb and teams_participant_controller.rb are used to manage the participants of teams.&lt;br /&gt;
* There is no functional test for teams_participant_controller.rb and unit test for teams_participant.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_participant.rb===&lt;br /&gt;
The teams_participant.rb is a model belonging to both users and teams. It is used when a team participant is created, listed or deleted.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_participant_controller.rb===&lt;br /&gt;
The teams_participant_controller support team participants management so the team participant:&lt;br /&gt;
* get a participant name by inputting part of the name&lt;br /&gt;
* list team participants of a team &lt;br /&gt;
* add a participant to a team&lt;br /&gt;
* remove a selected team participant from a team&lt;br /&gt;
* remove all team participants belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
The “team” object represents a team that consists students who are either participants of course or assignment.&lt;br /&gt;
a team will response to the request on: &lt;br /&gt;
&lt;br /&gt;
;get_participants : get participant in the team&lt;br /&gt;
;delete : delete a team member in the team&lt;br /&gt;
;get_node_type : will return “TeamNode”&lt;br /&gt;
;get_author_name : will return team’s name&lt;br /&gt;
;generate_team_name() : serialize the automatically generated team name (e.g. team 1, team 2, etc.)&lt;br /&gt;
;get_possible_team_members(name) : find a team member by name&lt;br /&gt;
;has_user(user : find a team member by user object&lt;br /&gt;
;add_member(user, assignment_id) : add a user to an assignment team&lt;br /&gt;
;copy_members(new_team) : copy current member in the team to the new team&lt;br /&gt;
;create_node_object(name, parent_id) : ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
;check_for_exisiting(parent, name, team_type) : check if the team name under the same assignment or course is in use.&lt;br /&gt;
;Delete_all_by_parent(parent) : delete all teams under the same course/assignment&lt;br /&gt;
;Randomize_all_by_parent(parent, team_type, team_size) : randomly assign team members&lt;br /&gt;
;generate_team_name(teamnameprefix) : generate team name with prefix (e.g. prefix_Team1) &lt;br /&gt;
;import_team_members(starting_index, row) : import user from specific index of users and length&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participant_controller.rb ===&lt;br /&gt;
Besides the above fixtures, we also need the following fixrure&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
&lt;br /&gt;
=== teams.rb ===&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== teams_participant_controller.rb ===&lt;br /&gt;
[[File:New.jpg]]&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb ===&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== teams_participant.rb ===&lt;br /&gt;
&lt;br /&gt;
** Test Delete to check if team node and the team user decreases by one&lt;br /&gt;
&lt;br /&gt;
=== teams_participant_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
** Test Create to check if the number of participant increases by one&lt;br /&gt;
** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
** Test Delete_select to check if the number of participant decreases by one&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
* remove&lt;br /&gt;
** test remove with valid user id&lt;br /&gt;
** test remove with invalid user id&lt;br /&gt;
&lt;br /&gt;
* create&lt;br /&gt;
** test create with valid user id&lt;br /&gt;
** test create with invalid user id&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
** test update with invalid id&lt;br /&gt;
** test update success&lt;br /&gt;
** test update fail (should remain the same)&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
** test edit&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* get participants&lt;br /&gt;
** test get participants&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
** test delete with team node&lt;br /&gt;
** test delete without team node&lt;br /&gt;
&lt;br /&gt;
* get_node_type &lt;br /&gt;
** test get node type&lt;br /&gt;
&lt;br /&gt;
* get_author_name&lt;br /&gt;
** test author name&lt;br /&gt;
&lt;br /&gt;
* generate_team_name() &lt;br /&gt;
** test generate team name from zero&lt;br /&gt;
** test generate team name from one&lt;br /&gt;
&lt;br /&gt;
* get_possible_team_members(name)&lt;br /&gt;
** test get possible team members by exact name&lt;br /&gt;
** test get possible team members by similar name&lt;br /&gt;
** test get possible team members by name in other team&lt;br /&gt;
&lt;br /&gt;
* has_user(user)&lt;br /&gt;
** test has user with valid user&lt;br /&gt;
** test has user with invalid user&lt;br /&gt;
&lt;br /&gt;
* add_member(user, assignment_id)&lt;br /&gt;
** test add member with valid user&lt;br /&gt;
** test add member already in team&lt;br /&gt;
** test add member without assignment id&lt;br /&gt;
** test add member when max team size reached&lt;br /&gt;
&lt;br /&gt;
* copy_members(new_team)&lt;br /&gt;
** test copy members to empty new team&lt;br /&gt;
** test copy members to nonempty new team&lt;br /&gt;
** test copy members with no member in current team&lt;br /&gt;
&lt;br /&gt;
* create_node_object(name, parent_id)&lt;br /&gt;
** ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
&lt;br /&gt;
* check_for_exisiting(parent, name, team_type)&lt;br /&gt;
** test check for exisiting with exisited name&lt;br /&gt;
** test check for exisiting with nonexisted name&lt;br /&gt;
&lt;br /&gt;
* delete_all_by_parent(parent)&lt;br /&gt;
** test delete with valid parents&lt;br /&gt;
** test delete with invalid parents&lt;br /&gt;
&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size)&lt;br /&gt;
** test randomize all by parent with exact number&lt;br /&gt;
** test randomize all by parent without enough people&lt;br /&gt;
** test randomize all by parent with remainder&lt;br /&gt;
&lt;br /&gt;
* generate_team_name(teamnameprefix)&lt;br /&gt;
** test generate prefix team name with valid name&lt;br /&gt;
** test generate prefix team name with duplicated name&lt;br /&gt;
&lt;br /&gt;
* import_team_members(starting_index, row) &lt;br /&gt;
** test import team members with valid index and row&lt;br /&gt;
** test import team members with invalid index and row&lt;br /&gt;
&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* There are two ''def get_participants'', the second one overwritten the first one, so the first one should be deleted.&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/unit/&amp;lt;filename&amp;gt; # for models&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/&amp;lt;filename&amp;gt; # for controllers&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84375</id>
		<title>CSC/ECE 517 Spring 2014/oss E1414 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84375"/>
		<updated>2014-04-10T00:29:49Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participant_controller.rb===&lt;br /&gt;
* teams_participant.rb and teams_participant_controller.rb are used to manage the participants of teams.&lt;br /&gt;
* There is no functional test for teams_participant_controller.rb and unit test for teams_participant.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_participant.rb===&lt;br /&gt;
The teams_participant.rb is a model belonging to both users and teams. It is used when a team participant is created, listed or deleted.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_participant_controller.rb===&lt;br /&gt;
The teams_participant_controller support team participants management so the team participant:&lt;br /&gt;
* get a participant name by inputting part of the name&lt;br /&gt;
* list team participants of a team &lt;br /&gt;
* add a participant to a team&lt;br /&gt;
* remove a selected team participant from a team&lt;br /&gt;
* remove all team participants belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
The “team” object represents a team that consists students who are either participants of course or assignment.&lt;br /&gt;
a team will response to the request on: &lt;br /&gt;
&lt;br /&gt;
;get_participants : get participant in the team&lt;br /&gt;
;delete : delete a team member in the team&lt;br /&gt;
;get_node_type : will return “TeamNode”&lt;br /&gt;
;get_author_name : will return team’s name&lt;br /&gt;
;generate_team_name() : serialize the automatically generated team name (e.g. team 1, team 2, etc.)&lt;br /&gt;
;get_possible_team_members(name) : find a team member by name&lt;br /&gt;
;has_user(user : find a team member by user object&lt;br /&gt;
;add_member(user, assignment_id) : add a user to an assignment team&lt;br /&gt;
;copy_members(new_team) : copy current member in the team to the new team&lt;br /&gt;
;create_node_object(name, parent_id) : ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
;check_for_exisiting(parent, name, team_type) : check if the team name under the same assignment or course is in use.&lt;br /&gt;
;Delete_all_by_parent(parent) : delete all teams under the same course/assignment&lt;br /&gt;
;Randomize_all_by_parent(parent, team_type, team_size) : randomly assign team members&lt;br /&gt;
;generate_team_name(teamnameprefix) : generate team name with prefix (e.g. prefix_Team1) &lt;br /&gt;
;import_team_members(starting_index, row) : import user from specific index of users and length&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participant_controller.rb ===&lt;br /&gt;
Besides the above fixtures, we also need the following fixrure&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
&lt;br /&gt;
=== teams.rb ===&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== teams_participant_controller.rb ===&lt;br /&gt;
[[File:New.jpg]]&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
For the methods in teams_user.rb, the scenarios would be like the following:&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== teams_participant_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
* remove&lt;br /&gt;
** test remove with valid user id&lt;br /&gt;
** test remove with invalid user id&lt;br /&gt;
&lt;br /&gt;
* create&lt;br /&gt;
** test create with valid user id&lt;br /&gt;
** test create with invalid user id&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
** test update with invalid id&lt;br /&gt;
** test update success&lt;br /&gt;
** test update fail (should remain the same)&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
** test edit&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* get participants&lt;br /&gt;
** test get participants&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
** test delete with team node&lt;br /&gt;
** test delete without team node&lt;br /&gt;
&lt;br /&gt;
* get_node_type &lt;br /&gt;
** test get node type&lt;br /&gt;
&lt;br /&gt;
* get_author_name&lt;br /&gt;
** test author name&lt;br /&gt;
&lt;br /&gt;
* generate_team_name() &lt;br /&gt;
** test generate team name from zero&lt;br /&gt;
** test generate team name from one&lt;br /&gt;
&lt;br /&gt;
* get_possible_team_members(name)&lt;br /&gt;
** test get possible team members by exact name&lt;br /&gt;
** test get possible team members by similar name&lt;br /&gt;
** test get possible team members by name in other team&lt;br /&gt;
&lt;br /&gt;
* has_user(user)&lt;br /&gt;
** test has user with valid user&lt;br /&gt;
** test has user with invalid user&lt;br /&gt;
&lt;br /&gt;
* add_member(user, assignment_id)&lt;br /&gt;
** test add member with valid user&lt;br /&gt;
** test add member already in team&lt;br /&gt;
** test add member without assignment id&lt;br /&gt;
** test add member when max team size reached&lt;br /&gt;
&lt;br /&gt;
* copy_members(new_team)&lt;br /&gt;
** test copy members to empty new team&lt;br /&gt;
** test copy members to nonempty new team&lt;br /&gt;
** test copy members with no member in current team&lt;br /&gt;
&lt;br /&gt;
* create_node_object(name, parent_id)&lt;br /&gt;
** ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
&lt;br /&gt;
* check_for_exisiting(parent, name, team_type)&lt;br /&gt;
** test check for exisiting with exisited name&lt;br /&gt;
** test check for exisiting with nonexisted name&lt;br /&gt;
&lt;br /&gt;
* delete_all_by_parent(parent)&lt;br /&gt;
** test delete with valid parents&lt;br /&gt;
** test delete with invalid parents&lt;br /&gt;
&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size)&lt;br /&gt;
** test randomize all by parent with exact number&lt;br /&gt;
** test randomize all by parent without enough people&lt;br /&gt;
** test randomize all by parent with remainder&lt;br /&gt;
&lt;br /&gt;
* generate_team_name(teamnameprefix)&lt;br /&gt;
** test generate prefix team name with valid name&lt;br /&gt;
** test generate prefix team name with duplicated name&lt;br /&gt;
&lt;br /&gt;
* import_team_members(starting_index, row) &lt;br /&gt;
** test import team members with valid index and row&lt;br /&gt;
** test import team members with invalid index and row&lt;br /&gt;
&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* There are two ''def get_participants'', the second one overwritten the first one, so the first one should be deleted.&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/unit/&amp;lt;filename&amp;gt; # for models&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/&amp;lt;filename&amp;gt; # for controllers&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84374</id>
		<title>CSC/ECE 517 Spring 2014/oss E1414 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84374"/>
		<updated>2014-04-10T00:08:38Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participant_controller.rb===&lt;br /&gt;
* teams_participant.rb and teams_participant_controller.rb are used to manage the participants of teams.&lt;br /&gt;
* There is no functional test for teams_participant_controller.rb and unit test for teams_participant.rb in the current version of expertiza codes.&lt;br /&gt;
=== advertise_for_partner.rb ===&lt;br /&gt;
* This controller takes over the advertisement function from the student_team_controller, and make the class more RESTful. &lt;br /&gt;
* It seems like there has been a functional test, but the class name and set up looks like the other class. It may be necessary to re-run, and even re-write the test&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* This model defines the relationship between team object and other objects. It also has other methods to handle related functions about team operation&lt;br /&gt;
* There exists a unit test for team model, but there are only two test cases. Also, some of the methods under team.rb are duplicated, or either marked as not working. Further research may be required before starting to do the test.&lt;br /&gt;
&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_participant.rb===&lt;br /&gt;
The teams_participant.rb is a model belonging to both users and teams. It is used when a team participant is created, listed or deleted.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_participant_controller.rb===&lt;br /&gt;
The teams_participant_controller support team participants management so the team participant:&lt;br /&gt;
* get a participant name by inputting part of the name&lt;br /&gt;
* list team participants of a team &lt;br /&gt;
* add a participant to a team&lt;br /&gt;
* remove a selected team participant from a team&lt;br /&gt;
* remove all team participants belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
The “team” object represents a team that consists students who are either participants of course or assignment.&lt;br /&gt;
a team will response to the request on: &lt;br /&gt;
&lt;br /&gt;
;get_participants : get participant in the team&lt;br /&gt;
;delete : delete a team member in the team&lt;br /&gt;
;get_node_type : will return “TeamNode”&lt;br /&gt;
;get_author_name : will return team’s name&lt;br /&gt;
;generate_team_name() : serialize the automatically generated team name (e.g. team 1, team 2, etc.)&lt;br /&gt;
;get_possible_team_members(name) : find a team member by name&lt;br /&gt;
;has_user(user : find a team member by user object&lt;br /&gt;
;add_member(user, assignment_id) : add a user to an assignment team&lt;br /&gt;
;copy_members(new_team) : copy current member in the team to the new team&lt;br /&gt;
;create_node_object(name, parent_id) : ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
;check_for_exisiting(parent, name, team_type) : check if the team name under the same assignment or course is in use.&lt;br /&gt;
;Delete_all_by_parent(parent) : delete all teams under the same course/assignment&lt;br /&gt;
;Randomize_all_by_parent(parent, team_type, team_size) : randomly assign team members&lt;br /&gt;
;generate_team_name(teamnameprefix) : generate team name with prefix (e.g. prefix_Team1) &lt;br /&gt;
;import_team_members(starting_index, row) : import user from specific index of users and length&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== fixtures use in common ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participant_controller.rb ===&lt;br /&gt;
Besides the above fixtures, we also need the following fixrure&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
&lt;br /&gt;
=== teams.rb ===&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
* join_team_requests.yml&lt;br /&gt;
* participants.yml&lt;br /&gt;
* nodes.yml&lt;br /&gt;
&lt;br /&gt;
== Use Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== teams_participant_controller.rb ===&lt;br /&gt;
[[File:New.jpg]]&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
[[File:Usecase_E1414_advertise.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
For the methods in teams_user.rb, the scenarios would be like the following:&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete to check if it could delete the team node and the team user&lt;br /&gt;
&lt;br /&gt;
* Remove_team&lt;br /&gt;
** Test Remove_team with valid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Remove_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
* Is_team_empty&lt;br /&gt;
** Test Is_team_empty with empty team&lt;br /&gt;
** Test Is_team_empty with non-empty team&lt;br /&gt;
&lt;br /&gt;
* Add_member_to_invited_team&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with valid user_id and invalid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and valid team_id&lt;br /&gt;
** Test Add_member_to_invited_team with invalid user_id and invalid team_id&lt;br /&gt;
&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participant_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== advertise_for_partner_controller.rb ===&lt;br /&gt;
* remove&lt;br /&gt;
** test remove with valid user id&lt;br /&gt;
** test remove with invalid user id&lt;br /&gt;
&lt;br /&gt;
* create&lt;br /&gt;
** test create with valid user id&lt;br /&gt;
** test create with invalid user id&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
** test update with invalid id&lt;br /&gt;
** test update success&lt;br /&gt;
** test update fail (should remain the same)&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
** test edit&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* get participants&lt;br /&gt;
** test get participants&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
** test delete with team node&lt;br /&gt;
** test delete without team node&lt;br /&gt;
&lt;br /&gt;
* get_node_type &lt;br /&gt;
** test get node type&lt;br /&gt;
&lt;br /&gt;
* get_author_name&lt;br /&gt;
** test author name&lt;br /&gt;
&lt;br /&gt;
* generate_team_name() &lt;br /&gt;
** test generate team name from zero&lt;br /&gt;
** test generate team name from one&lt;br /&gt;
&lt;br /&gt;
* get_possible_team_members(name)&lt;br /&gt;
** test get possible team members by exact name&lt;br /&gt;
** test get possible team members by similar name&lt;br /&gt;
** test get possible team members by name in other team&lt;br /&gt;
&lt;br /&gt;
* has_user(user)&lt;br /&gt;
** test has user with valid user&lt;br /&gt;
** test has user with invalid user&lt;br /&gt;
&lt;br /&gt;
* add_member(user, assignment_id)&lt;br /&gt;
** test add member with valid user&lt;br /&gt;
** test add member already in team&lt;br /&gt;
** test add member without assignment id&lt;br /&gt;
** test add member when max team size reached&lt;br /&gt;
&lt;br /&gt;
* copy_members(new_team)&lt;br /&gt;
** test copy members to empty new team&lt;br /&gt;
** test copy members to nonempty new team&lt;br /&gt;
** test copy members with no member in current team&lt;br /&gt;
&lt;br /&gt;
* create_node_object(name, parent_id)&lt;br /&gt;
** ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
&lt;br /&gt;
* check_for_exisiting(parent, name, team_type)&lt;br /&gt;
** test check for exisiting with exisited name&lt;br /&gt;
** test check for exisiting with nonexisted name&lt;br /&gt;
&lt;br /&gt;
* delete_all_by_parent(parent)&lt;br /&gt;
** test delete with valid parents&lt;br /&gt;
** test delete with invalid parents&lt;br /&gt;
&lt;br /&gt;
* randomize_all_by_parent(parent, team_type, team_size)&lt;br /&gt;
** test randomize all by parent with exact number&lt;br /&gt;
** test randomize all by parent without enough people&lt;br /&gt;
** test randomize all by parent with remainder&lt;br /&gt;
&lt;br /&gt;
* generate_team_name(teamnameprefix)&lt;br /&gt;
** test generate prefix team name with valid name&lt;br /&gt;
** test generate prefix team name with duplicated name&lt;br /&gt;
&lt;br /&gt;
* import_team_members(starting_index, row) &lt;br /&gt;
** test import team members with valid index and row&lt;br /&gt;
** test import team members with invalid index and row&lt;br /&gt;
&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller.rb ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
=== team.rb ===&lt;br /&gt;
* There are two ''def get_participants'', the second one overwritten the first one, so the first one should be deleted.&lt;br /&gt;
&lt;br /&gt;
== Running Tests ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/unit/&amp;lt;filename&amp;gt; # for models&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/&amp;lt;filename&amp;gt; # for controllers&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers from our previous work to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:New.jpg&amp;diff=84373</id>
		<title>File:New.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:New.jpg&amp;diff=84373"/>
		<updated>2014-04-10T00:07:14Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84340</id>
		<title>CSC/ECE 517 Spring 2014/oss E1414 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84340"/>
		<updated>2014-04-09T20:10:03Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: /* app/models/teams_users.rb &amp;amp; app/controllers/teams_users_controller.rb &amp;amp;app/models/teams_participant.rb &amp;amp; app/controllers/teams_participant_controller.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_participant.rb===&lt;br /&gt;
The teams_participant.rb is a model belonging to both users and teams. It is used when a team participant is created, listed or deleted.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_participant_controller.rb===&lt;br /&gt;
The teams_participant_controller support team participants management so the team participant:&lt;br /&gt;
* get a participant name by inputting part of the name&lt;br /&gt;
* list team participants of a team &lt;br /&gt;
* add a participant to a team&lt;br /&gt;
* remove a selected team participant from a team&lt;br /&gt;
* remove all team participants belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
The “team” object represents a team that consists students who are either participants of course or assignment.&lt;br /&gt;
a team will response to the request on: &lt;br /&gt;
&lt;br /&gt;
;get_participants : get participant in the team&lt;br /&gt;
;delete : delete a team member in the team&lt;br /&gt;
;get_node_type : will return “TeamNode”&lt;br /&gt;
;get_author_name : will return team’s name&lt;br /&gt;
;generate_team_name() : serialize the automatically generated team name (e.g. team 1, team 2, etc.)&lt;br /&gt;
;get_possible_team_members(name) : find a team member by name&lt;br /&gt;
;has_user(user : find a team member by user object&lt;br /&gt;
;add_member(user, assignment_id) : add a user to an assignment team&lt;br /&gt;
;copy_members(new_team) : copy current member in the team to the new team&lt;br /&gt;
;create_node_object(name, parent_id) : ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
;check_for_exisiting(parent, name, team_type) : check if the team name under the same assignment or course is in use.&lt;br /&gt;
;Delete_all_by_parent(parent) : delete all teams under the same course/assignment&lt;br /&gt;
;Randomize_all_by_parent(parent, team_type, team_size) : randomly assign team members&lt;br /&gt;
;generate_team_name(teamnameprefix) : generate team name with prefix (e.g. prefix_Team1) &lt;br /&gt;
;import_team_members(starting_index, row) : import user from specific index of users and length&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participant_controller.rb===&lt;br /&gt;
* teams_participant.rb and teams_participant_controller.rb are used to manage the participants of teams.&lt;br /&gt;
* There is no functional test for teams_participant_controller.rb and unit test for teams_participant.rb in the current version of expertiza codes.&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_users.rb &amp;amp; app/controllers/teams_users_controller.rb ===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
=== app/models/teams_participant.rb &amp;amp; app/controllers/teams_participant_controller.rb ===&lt;br /&gt;
Besides the above fixtures, we also need the following fixrure&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
&lt;br /&gt;
== User Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_participant_controller.rb ===&lt;br /&gt;
[[File:Usercase.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_users.rb &amp;amp; app/controllers/teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_participant.rb &amp;amp; app/controllers/teams_participant_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
== Deployment ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/functional/student_team_controller.rb&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/teams_controller&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84339</id>
		<title>CSC/ECE 517 Spring 2014/oss E1414 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84339"/>
		<updated>2014-04-09T20:08:13Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: /* app/models/teams_users.rb &amp;amp; app/controllers/teams_users_controller.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_participant.rb===&lt;br /&gt;
The teams_participant.rb is a model belonging to both users and teams. It is used when a team participant is created, listed or deleted.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_participant_controller.rb===&lt;br /&gt;
The teams_participant_controller support team participants management so the team participant:&lt;br /&gt;
* get a participant name by inputting part of the name&lt;br /&gt;
* list team participants of a team &lt;br /&gt;
* add a participant to a team&lt;br /&gt;
* remove a selected team participant from a team&lt;br /&gt;
* remove all team participants belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
The “team” object represents a team that consists students who are either participants of course or assignment.&lt;br /&gt;
a team will response to the request on: &lt;br /&gt;
&lt;br /&gt;
;get_participants : get participant in the team&lt;br /&gt;
;delete : delete a team member in the team&lt;br /&gt;
;get_node_type : will return “TeamNode”&lt;br /&gt;
;get_author_name : will return team’s name&lt;br /&gt;
;generate_team_name() : serialize the automatically generated team name (e.g. team 1, team 2, etc.)&lt;br /&gt;
;get_possible_team_members(name) : find a team member by name&lt;br /&gt;
;has_user(user : find a team member by user object&lt;br /&gt;
;add_member(user, assignment_id) : add a user to an assignment team&lt;br /&gt;
;copy_members(new_team) : copy current member in the team to the new team&lt;br /&gt;
;create_node_object(name, parent_id) : ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
;check_for_exisiting(parent, name, team_type) : check if the team name under the same assignment or course is in use.&lt;br /&gt;
;Delete_all_by_parent(parent) : delete all teams under the same course/assignment&lt;br /&gt;
;Randomize_all_by_parent(parent, team_type, team_size) : randomly assign team members&lt;br /&gt;
;generate_team_name(teamnameprefix) : generate team name with prefix (e.g. prefix_Team1) &lt;br /&gt;
;import_team_members(starting_index, row) : import user from specific index of users and length&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participant_controller.rb===&lt;br /&gt;
* teams_participant.rb and teams_participant_controller.rb are used to manage the participants of teams.&lt;br /&gt;
* There is no functional test for teams_participant_controller.rb and unit test for teams_participant.rb in the current version of expertiza codes.&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_users.rb &amp;amp; app/controllers/teams_users_controller.rb &amp;amp;app/models/teams_participant.rb &amp;amp; app/controllers/teams_participant_controller.rb===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
&lt;br /&gt;
== User Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_participant_controller.rb ===&lt;br /&gt;
[[File:Usercase.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_users.rb &amp;amp; app/controllers/teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_participant.rb &amp;amp; app/controllers/teams_participant_controller.rb ===&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
== Deployment ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/functional/student_team_controller.rb&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/teams_controller&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84338</id>
		<title>CSC/ECE 517 Spring 2014/oss E1414 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84338"/>
		<updated>2014-04-09T20:05:11Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_participant.rb===&lt;br /&gt;
The teams_participant.rb is a model belonging to both users and teams. It is used when a team participant is created, listed or deleted.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_participant_controller.rb===&lt;br /&gt;
The teams_participant_controller support team participants management so the team participant:&lt;br /&gt;
* get a participant name by inputting part of the name&lt;br /&gt;
* list team participants of a team &lt;br /&gt;
* add a participant to a team&lt;br /&gt;
* remove a selected team participant from a team&lt;br /&gt;
* remove all team participants belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
The “team” object represents a team that consists students who are either participants of course or assignment.&lt;br /&gt;
a team will response to the request on: &lt;br /&gt;
&lt;br /&gt;
;get_participants : get participant in the team&lt;br /&gt;
;delete : delete a team member in the team&lt;br /&gt;
;get_node_type : will return “TeamNode”&lt;br /&gt;
;get_author_name : will return team’s name&lt;br /&gt;
;generate_team_name() : serialize the automatically generated team name (e.g. team 1, team 2, etc.)&lt;br /&gt;
;get_possible_team_members(name) : find a team member by name&lt;br /&gt;
;has_user(user : find a team member by user object&lt;br /&gt;
;add_member(user, assignment_id) : add a user to an assignment team&lt;br /&gt;
;copy_members(new_team) : copy current member in the team to the new team&lt;br /&gt;
;create_node_object(name, parent_id) : ‘’there is a TODO on this method indicated that this is not working’’ &lt;br /&gt;
;check_for_exisiting(parent, name, team_type) : check if the team name under the same assignment or course is in use.&lt;br /&gt;
;Delete_all_by_parent(parent) : delete all teams under the same course/assignment&lt;br /&gt;
;Randomize_all_by_parent(parent, team_type, team_size) : randomly assign team members&lt;br /&gt;
;generate_team_name(teamnameprefix) : generate team name with prefix (e.g. prefix_Team1) &lt;br /&gt;
;import_team_members(starting_index, row) : import user from specific index of users and length&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participant_controller.rb===&lt;br /&gt;
* teams_participant.rb and teams_participant_controller.rb are used to manage the participants of teams.&lt;br /&gt;
* There is no functional test for teams_participant_controller.rb and unit test for teams_participant.rb in the current version of expertiza codes.&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_users.rb &amp;amp; app/controllers/teams_users_controller.rb &amp;amp;app/models/teams_participant.rb &amp;amp; app/controllers/teams_participant_controller.rb===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
&lt;br /&gt;
== User Case Diagram ==&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_participant_controller.rb ===&lt;br /&gt;
[[File:Usercase.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_users.rb &amp;amp; app/controllers/teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
== Deployment ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/functional/student_team_controller.rb&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/teams_controller&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Usercase.jpg&amp;diff=84337</id>
		<title>File:Usercase.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Usercase.jpg&amp;diff=84337"/>
		<updated>2014-04-09T20:02:26Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84335</id>
		<title>CSC/ECE 517 Spring 2014/oss E1414 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84335"/>
		<updated>2014-04-09T19:57:55Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: /* app/models/teams_users.rb &amp;amp; app/controllers/teams_users_controller.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_participant.rb===&lt;br /&gt;
The teams_participant.rb is a model belonging to both users and teams. It is used when a team participant is created, listed or deleted.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_participant_controller.rb===&lt;br /&gt;
The teams_participant_controller support team participants management so the team participant:&lt;br /&gt;
* get a participant name by inputting part of the name&lt;br /&gt;
* list team participants of a team &lt;br /&gt;
* add a participant to a team&lt;br /&gt;
* remove a selected team participant from a team&lt;br /&gt;
* remove all team participants belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participant_controller.rb===&lt;br /&gt;
* teams_participant.rb and teams_participant_controller.rb are used to manage the participants of teams.&lt;br /&gt;
* There is no functional test for teams_participant_controller.rb and unit test for teams_participant.rb in the current version of expertiza codes.&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_users.rb &amp;amp; app/controllers/teams_users_controller.rb &amp;amp;app/models/teams_participant.rb &amp;amp; app/controllers/teams_participant_controller.rb===&lt;br /&gt;
* teams.yml&lt;br /&gt;
* users.yml &lt;br /&gt;
* teams_users.yml&lt;br /&gt;
* courses.yml&lt;br /&gt;
* assignments.yml&lt;br /&gt;
* teams_participant.yml&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_users.rb &amp;amp; app/controllers/teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
== Deployment ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/functional/student_team_controller.rb&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/teams_controller&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84334</id>
		<title>CSC/ECE 517 Spring 2014/oss E1414 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84334"/>
		<updated>2014-04-09T19:56:31Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: /* Background */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_participant.rb===&lt;br /&gt;
The teams_participant.rb is a model belonging to both users and teams. It is used when a team participant is created, listed or deleted.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_participant_controller.rb===&lt;br /&gt;
The teams_participant_controller support team participants management so the team participant:&lt;br /&gt;
* get a participant name by inputting part of the name&lt;br /&gt;
* list team participants of a team &lt;br /&gt;
* add a participant to a team&lt;br /&gt;
* remove a selected team participant from a team&lt;br /&gt;
* remove all team participants belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
=== teams_participant.rb &amp;amp; teams_participant_controller.rb===&lt;br /&gt;
* teams_participant.rb and teams_participant_controller.rb are used to manage the participants of teams.&lt;br /&gt;
* There is no functional test for teams_participant_controller.rb and unit test for teams_participant.rb in the current version of expertiza codes.&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_users.rb &amp;amp; app/controllers/teams_users_controller.rb ===&lt;br /&gt;
* Teams.yml&lt;br /&gt;
* Usres.yml &lt;br /&gt;
* Teams_Uers.yml&lt;br /&gt;
* Courses.yml&lt;br /&gt;
* Assignments.yml&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_users.rb &amp;amp; app/controllers/teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
== Deployment ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/functional/student_team_controller.rb&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/teams_controller&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84333</id>
		<title>CSC/ECE 517 Spring 2014/oss E1414 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1414_st&amp;diff=84333"/>
		<updated>2014-04-09T19:55:20Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1414: Testing classes related to teams=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project will be an extension of our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Spring_2014/oss_E1406_st previous E1406 project]. For the previous project, we did some refactoring and testing for the controllers related to teams. This time, we are going to reuse most of our test environment, but extend the tests to other team-related classes. We also expect to examine and report the code that may require refactoring.&lt;br /&gt;
== Test Environment ==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/models/teams_users.rb===&lt;br /&gt;
The teams_users.rb is a model belonging to both users and teams. It is used when a user is added to a team.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_users_controller.rb===&lt;br /&gt;
The teams_users_controller support team member management for instructor/TA accounts&lt;br /&gt;
Instruction/TA can:&lt;br /&gt;
* get a user name by inputting part of the name&lt;br /&gt;
* list team members of a team &lt;br /&gt;
* add a user to a team&lt;br /&gt;
* remove a team member from a team&lt;br /&gt;
* remove all members belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/advertise_for_partners_controller.rb ===&lt;br /&gt;
The advertise_for_partners_controller work with the student_team_controllers, allowing student manage advertisement for their teams.&lt;br /&gt;
&lt;br /&gt;
A student can:&lt;br /&gt;
* create a new advertisement for the team&lt;br /&gt;
* edit the advertisement content&lt;br /&gt;
* remove advertisement record from the table for the specific team&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_participant.rb===&lt;br /&gt;
The teams_participant.rb is a model belonging to both users and teams. It is used when a team participant is created, listed or deleted.&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/teams_participant_controller.rb===&lt;br /&gt;
The teams_participant_controller support team participants management so the team participant:&lt;br /&gt;
* get a participant name by inputting part of the name&lt;br /&gt;
* list team participants of a team &lt;br /&gt;
* add a participant to a team&lt;br /&gt;
* remove a selected team participant from a team&lt;br /&gt;
* remove all team participants belonging to an item&lt;br /&gt;
&lt;br /&gt;
=== app/models/team.rb ===&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
=== teams_users.rb &amp;amp; teams_users_controller.rb===&lt;br /&gt;
* Teams_users.rb and teams_users_controller.rb are used for Instructor/TA to manage the members of teams.&lt;br /&gt;
* There is no functional test for teams_users_controller.rb and unit test for teams_users.rb in the current version of expertiza codes.&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
To set up our testing for the models and controllers, we need some fixtures to support. &lt;br /&gt;
Fixtures needed for corresponding classes are listed below&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_users.rb &amp;amp; app/controllers/teams_users_controller.rb ===&lt;br /&gt;
* Teams.yml&lt;br /&gt;
* Usres.yml &lt;br /&gt;
* Teams_Uers.yml&lt;br /&gt;
* Courses.yml&lt;br /&gt;
* Assignments.yml&lt;br /&gt;
&lt;br /&gt;
== Testing Scenarios ==&lt;br /&gt;
&lt;br /&gt;
=== app/models/teams_users.rb &amp;amp; app/controllers/teams_users_controller.rb ===&lt;br /&gt;
[[File:TeamUsersStory.png]]&lt;br /&gt;
&lt;br /&gt;
Based on the user story of the teams_users_controller.rb, there are also several sub-scenarios for each method in the user story.&lt;br /&gt;
&lt;br /&gt;
* Auto_complete_for_user_name:&lt;br /&gt;
** Test auto_complete_for_user_name with valid user name&lt;br /&gt;
** Test auto_complete_for_user_name with invalid user name&lt;br /&gt;
&lt;br /&gt;
* List&lt;br /&gt;
** Test List with valid team id&lt;br /&gt;
** Test List with invalid team id&lt;br /&gt;
&lt;br /&gt;
* New&lt;br /&gt;
** Test New with valid team id&lt;br /&gt;
** Test New with invalid team id&lt;br /&gt;
&lt;br /&gt;
* Create&lt;br /&gt;
** Test Create with valid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
** Test Create with invalid team id&lt;br /&gt;
*** Test Create with valid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is not reached&lt;br /&gt;
*** Test Create with valid user id and maximum member number is reached&lt;br /&gt;
*** Test Create with invalid user id and maximum member number is reached&lt;br /&gt;
&lt;br /&gt;
* Delete&lt;br /&gt;
** Test Delete with valid user id&lt;br /&gt;
** Test Delete with invalid user id&lt;br /&gt;
&lt;br /&gt;
* Delete_select&lt;br /&gt;
** Test Delete_select with valid item id&lt;br /&gt;
** Test Delete_select with invalid item id&lt;br /&gt;
&lt;br /&gt;
== Possible Refacotring ==&lt;br /&gt;
=== advertise_for_team_controller ===&lt;br /&gt;
* ''update'' should be ''edit'' (this is mentioned in the comments of code)&lt;br /&gt;
* ''edit'' should be reexamined since it is only retrieving the team object&lt;br /&gt;
* ''new'' is empty, so it should be removed&lt;br /&gt;
&lt;br /&gt;
== Deployment ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/functional/student_team_controller.rb&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/teams_controller&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84251</id>
		<title>CSC/ECE 517 Spring 2014/oss E1406 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84251"/>
		<updated>2014-04-01T03:09:02Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: /* student_team_controller */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1406: Improve tests &amp;amp; investigate regex warnings for team functionality=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/controllers/teams_controller.rb ===&lt;br /&gt;
 &lt;br /&gt;
teams_controller contains functionalities for team management for instructor/TA accounts. &lt;br /&gt;
Instructor/TA can:&lt;br /&gt;
* view current teams&lt;br /&gt;
* create new teams&lt;br /&gt;
* import/export teams&lt;br /&gt;
* delete all teams/delete specified team&lt;br /&gt;
* copy existing teams from a course down to an assignment(inherit)&lt;br /&gt;
* update team's information&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/student_team_controller.rb ===&lt;br /&gt;
The student_team_controller support team management for student account.&lt;br /&gt;
student can&lt;br /&gt;
* create team&lt;br /&gt;
* view current team (including team invitations received and sent)&lt;br /&gt;
* advertise for their team&lt;br /&gt;
* remove the advertise for their team&lt;br /&gt;
* leave the team&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
There were no functional tests written on the two controllers to detect bugs, as well as confirming they are functional by itself and after integration.&lt;br /&gt;
&lt;br /&gt;
Our goal is to add comprehensive functional tests and integration tests to the two controllers to provide a preferable test suite for the future developers. &lt;br /&gt;
&lt;br /&gt;
Also, as the classes are influenced by the changes from other, we are also responsible for fixing some of the bugs, refactoring the method names to a better ones, as well as reporting the bugs found in the testing process.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
Overall: contribute to the code coverage, ideally having overall coverage increase 2%&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
* def advertise_for_partners  # change to “advertise”&lt;br /&gt;
* def remove # change to “remove_advertisment”&lt;br /&gt;
* def review # remove this method&lt;br /&gt;
&lt;br /&gt;
===teams_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
&lt;br /&gt;
== Deployment ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/functional/student_team_controller.rb&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/teams_controller&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
;Total Number of Tests : 37&lt;br /&gt;
;Previous Coverage : 22.32%&lt;br /&gt;
;Current Coverage : 24.08% &lt;br /&gt;
&lt;br /&gt;
===Testing Scenarios===&lt;br /&gt;
====student_team_controller====&lt;br /&gt;
Most of the test case are straightforward. There are some of the test cases was commented out due to bug in the controller&lt;br /&gt;
* View student team (GET #view)&lt;br /&gt;
* Edit team (GET #edit)&lt;br /&gt;
* Create team with valid name (POST #create)&lt;br /&gt;
* Create team with name in use (POST #create)&lt;br /&gt;
* Update valid team name (POST #update) &lt;br /&gt;
* Update team name in use (POST #update)&lt;br /&gt;
* Update with current team name (POST #update)&lt;br /&gt;
* Advertise (GET #advertise)&lt;br /&gt;
''This is currently commented out in the committed code. It seems like the method is never called. It raises missing template error upon every call. ''&lt;br /&gt;
The &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; method was previously named advertise_for_partners, but renamed due to ambiguity as there is another class with the same name. &lt;br /&gt;
&lt;br /&gt;
* Remove advertisement (GET #remove_advertisement )&lt;br /&gt;
The &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; method was previously named remove, but renamed to avoid ambiguity&lt;br /&gt;
This method is never called as well, but it is functional as it do not require any template.&lt;br /&gt;
* Leave student team (GET #leave)&lt;br /&gt;
''This is currently commented out in the committed code, because it will raise error every time when called.''&lt;br /&gt;
It seems like problem happens on &lt;br /&gt;
  line 96: other_members = TeamsUser.where( ['team_id = ?', params[:team_id]]).first&lt;br /&gt;
  line 97: if other_members.length == 0&lt;br /&gt;
This will raise error due to the calling length of other_members, which is a single object but not an array.&lt;br /&gt;
Also, the related record seems to be remain undeleted in the database.&lt;br /&gt;
&lt;br /&gt;
====teams_controller====&lt;br /&gt;
Current test cases are as following.&lt;br /&gt;
* Create team should increase the number of teams by 1(GET #create)&lt;br /&gt;
* Create team should increase the number of team nodes by 1(GET #create)&lt;br /&gt;
* Create team with existing name (POST #create)&lt;br /&gt;
* Create team should redirect to list assignments (POST #create)&lt;br /&gt;
* Delete all teams (GET #delete_all)&lt;br /&gt;
* Delete all teams should redirect to list (GET #delete_all)&lt;br /&gt;
* List should receive assignment (GET #list)&lt;br /&gt;
* List should receive course (GET #list)&lt;br /&gt;
* New should assign parent (GET #new)&lt;br /&gt;
* Update team should redirect (POST #update)&lt;br /&gt;
* Update team should have validate name (POST #update)&lt;br /&gt;
* Edit team should have time (POST #edit)&lt;br /&gt;
* Delete team should redirect (POST #delete)&lt;br /&gt;
* Delete team should decrease the number of teams by 1(GET #delete)&lt;br /&gt;
* Delete team should decrease the number of team nodes by 1(GET #delete)&lt;br /&gt;
* Inherit team should redirect (POST #inherit)&lt;br /&gt;
* Bequeath team should redirect (POST #bequeath)&lt;br /&gt;
The methods in the following are ignored in testing since they are never used in current codes.&lt;br /&gt;
* create_teams_view&lt;br /&gt;
* create_teams&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not. &lt;br /&gt;
&lt;br /&gt;
==Result==&lt;br /&gt;
&lt;br /&gt;
In this section, we will show the result form SimpleCov. The coverage is 24.08%.&lt;br /&gt;
&lt;br /&gt;
[[File:Result.png]]&lt;br /&gt;
&lt;br /&gt;
==Future Works==&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
''Please note that this bug was reported fixed in the newest version of master branch of expertiza, but the fix came too late''&lt;br /&gt;
&lt;br /&gt;
There are several error raised from ''leave'' method need to be fixed, as mentioned above. Future teams may need to add tests on it as soon as it fixed, since it is a crucial functionality of the student team. &lt;br /&gt;
&lt;br /&gt;
Also, methods that seems like not being used, such as &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; may need to be double checked and see if they are redundant.&lt;br /&gt;
===teams_controller===&lt;br /&gt;
The method &amp;lt;code&amp;gt;create_teams_view&amp;lt;/code&amp;gt; does not be used at all. So it is safe to delete it.&lt;br /&gt;
&lt;br /&gt;
The method &amp;lt;code&amp;gt;create_teams&amp;lt;/code&amp;gt; calls the method &amp;lt;code&amp;gt;randomize_all_by_parent&amp;lt;/code&amp;gt;, which is not correct. The developer may want to fix these bugs. &lt;br /&gt;
&lt;br /&gt;
It's possible that we can write more testing cases if we improve the fixture.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84249</id>
		<title>CSC/ECE 517 Spring 2014/oss E1406 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84249"/>
		<updated>2014-04-01T03:08:37Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1406: Improve tests &amp;amp; investigate regex warnings for team functionality=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/controllers/teams_controller.rb ===&lt;br /&gt;
 &lt;br /&gt;
teams_controller contains functionalities for team management for instructor/TA accounts. &lt;br /&gt;
Instructor/TA can:&lt;br /&gt;
* view current teams&lt;br /&gt;
* create new teams&lt;br /&gt;
* import/export teams&lt;br /&gt;
* delete all teams/delete specified team&lt;br /&gt;
* copy existing teams from a course down to an assignment(inherit)&lt;br /&gt;
* update team's information&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/student_team_controller.rb ===&lt;br /&gt;
The student_team_controller support team management for student account.&lt;br /&gt;
student can&lt;br /&gt;
* create team&lt;br /&gt;
* view current team (including team invitations received and sent)&lt;br /&gt;
* advertise for their team&lt;br /&gt;
* remove the advertise for their team&lt;br /&gt;
* leave the team&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
There were no functional tests written on the two controllers to detect bugs, as well as confirming they are functional by itself and after integration.&lt;br /&gt;
&lt;br /&gt;
Our goal is to add comprehensive functional tests and integration tests to the two controllers to provide a preferable test suite for the future developers. &lt;br /&gt;
&lt;br /&gt;
Also, as the classes are influenced by the changes from other, we are also responsible for fixing some of the bugs, refactoring the method names to a better ones, as well as reporting the bugs found in the testing process.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
Overall: contribute to the code coverage, ideally having overall coverage increase 2%&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
* def advertise_for_partners  # change to “advertise”&lt;br /&gt;
* def remove # change to “remove_advertisment”&lt;br /&gt;
* def review # remove this method&lt;br /&gt;
&lt;br /&gt;
===teams_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
&lt;br /&gt;
== Deployment ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/functional/student_team_controller.rb&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/teams_controller&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
;Total Number of Tests : 37&lt;br /&gt;
;Previous Coverage : 22.32%&lt;br /&gt;
;Current Coverage : 24.08% &lt;br /&gt;
&lt;br /&gt;
===Testing Scenarios===&lt;br /&gt;
====student_team_controller====&lt;br /&gt;
Most of the test case are straightforward. There are some of the test cases was commented out due to bug in the controller&lt;br /&gt;
* View student team (GET #view)&lt;br /&gt;
* Edit team (GET #edit)&lt;br /&gt;
* Create team with valid name (POST #create)&lt;br /&gt;
* Create team with name in use (POST #create)&lt;br /&gt;
* Update valid team name (POST #update) &lt;br /&gt;
* Update team name in use (POST #update)&lt;br /&gt;
* Update with current team name (POST #update)&lt;br /&gt;
* Advertise (GET #advertise)&lt;br /&gt;
''This is currently commented out in the committed code. It seems like the method is never called. It raises missing template error upon every call. ''&lt;br /&gt;
The &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; method was previously named advertise_for_partners, but renamed due to ambiguity as there is another class with the same name. &lt;br /&gt;
&lt;br /&gt;
* Remove advertisement (GET #remove_advertisement )&lt;br /&gt;
The &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; method was previously named remove, but renamed to avoid ambiguity&lt;br /&gt;
This method is never called as well, but it is functional as it do not require any template.&lt;br /&gt;
* Leave student team (GET #leave)&lt;br /&gt;
''This is currently commented out in the committed code, because it will raise error every time when called.''&lt;br /&gt;
It seems like problem happens on &lt;br /&gt;
  line 96: other_members = TeamsUser.where( ['team_id = ?', params[:team_id]]).first&lt;br /&gt;
  line 97: if other_members.length == 0&lt;br /&gt;
This will raise error due to the calling length of other_members, which is a single object but not an array.&lt;br /&gt;
Also, the related record seems to be remain undeleted in the database.&lt;br /&gt;
&lt;br /&gt;
====teams_controller====&lt;br /&gt;
Current test cases are as following.&lt;br /&gt;
* Create team should increase the number of teams by 1(GET #create)&lt;br /&gt;
* Create team should increase the number of team nodes by 1(GET #create)&lt;br /&gt;
* Create team with existing name (POST #create)&lt;br /&gt;
* Create team should redirect to list assignments (POST #create)&lt;br /&gt;
* Delete all teams (GET #delete_all)&lt;br /&gt;
* Delete all teams should redirect to list (GET #delete_all)&lt;br /&gt;
* List should receive assignment (GET #list)&lt;br /&gt;
* List should receive course (GET #list)&lt;br /&gt;
* New should assign parent (GET #new)&lt;br /&gt;
* Update team should redirect (POST #update)&lt;br /&gt;
* Update team should have validate name (POST #update)&lt;br /&gt;
* Edit team should have time (POST #edit)&lt;br /&gt;
* Delete team should redirect (POST #delete)&lt;br /&gt;
* Delete team should decrease the number of teams by 1(GET #delete)&lt;br /&gt;
* Delete team should decrease the number of team nodes by 1(GET #delete)&lt;br /&gt;
* Inherit team should redirect (POST #inherit)&lt;br /&gt;
* Bequeath team should redirect (POST #bequeath)&lt;br /&gt;
The methods in the following are ignored in testing since they are never used in current codes.&lt;br /&gt;
* create_teams_view&lt;br /&gt;
* create_teams&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not. &lt;br /&gt;
&lt;br /&gt;
==Result==&lt;br /&gt;
&lt;br /&gt;
In this section, we will show the result form SimpleCov. The coverage is 24.08%.&lt;br /&gt;
&lt;br /&gt;
[[File:Result.png]]&lt;br /&gt;
&lt;br /&gt;
==Future Works==&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
''Please note that this bug was reported fixed in the newest version of master branch of expertiza, but the fix came too late''&lt;br /&gt;
&lt;br /&gt;
There are several error raised from ''leave'' method need to be fixed, as mentioned above. Future teams may need to add tests on it as soon as it fixed, since it is a crucial functionality of the student team. &lt;br /&gt;
&lt;br /&gt;
Also, methods that seems like not being used, such as &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; may need to be double checked and see if they are redundant.&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
The method &amp;lt;code&amp;gt;create_teams_view&amp;lt;/code&amp;gt; does not be used at all. So it is safe to delete it.&lt;br /&gt;
&lt;br /&gt;
The method &amp;lt;code&amp;gt;create_teams&amp;lt;/code&amp;gt; calls the method &amp;lt;code&amp;gt;randomize_all_by_parent&amp;lt;/code&amp;gt;, which is not correct. The developer may want to fix these bugs. &lt;br /&gt;
&lt;br /&gt;
It's possible that we can write more testing cases if we improve the fixture.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84243</id>
		<title>CSC/ECE 517 Spring 2014/oss E1406 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84243"/>
		<updated>2014-04-01T02:48:52Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1406: Improve tests &amp;amp; investigate regex warnings for team functionality=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/controllers/teams_controller.rb ===&lt;br /&gt;
 &lt;br /&gt;
teams_controller contains functionalities for team management for instructor/TA accounts. &lt;br /&gt;
Instructor/TA can:&lt;br /&gt;
* view current teams&lt;br /&gt;
* create new teams&lt;br /&gt;
* import/export teams&lt;br /&gt;
* delete all teams/delete specified team&lt;br /&gt;
* copy existing teams from a course down to an assignment(inherit)&lt;br /&gt;
* update team's information&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/student_team_controller.rb ===&lt;br /&gt;
The student_team_controller support team management for student account.&lt;br /&gt;
student can&lt;br /&gt;
* create team&lt;br /&gt;
* view current team (including team invitations received and sent)&lt;br /&gt;
* advertise for their team&lt;br /&gt;
* remove the advertise for their team&lt;br /&gt;
* leave the team&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
There were no functional tests written on the two controllers to detect bugs, as well as confirming they are functional by itself and after integration.&lt;br /&gt;
&lt;br /&gt;
Our goal is to add comprehensive functional tests and integration tests to the two controllers to provide a preferable test suite for the future developers. &lt;br /&gt;
&lt;br /&gt;
Also, as the classes are influenced by the changes from other, we are also responsible for fixing some of the bugs, refactoring the method names to a better ones, as well as reporting the bugs found in the testing process.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
Overall: contribute to the code coverage, ideally having overall coverage increase 2%&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
* def advertise_for_partners  # change to “advertise”&lt;br /&gt;
* def remove # change to “remove_advertisment”&lt;br /&gt;
* def review # remove this method&lt;br /&gt;
&lt;br /&gt;
===teams_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
&lt;br /&gt;
== Deployment ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/functional/student_team_controller.rb&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/teams_controller&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
;Total Number of Tests : 37&lt;br /&gt;
;Previous Coverage : 22.32%&lt;br /&gt;
;Current Coverage : 24.08% &lt;br /&gt;
&lt;br /&gt;
===Testing Scenarios===&lt;br /&gt;
====student_team_controller====&lt;br /&gt;
Most of the test case are straightforward. There are some of the test cases was commented out due to bug in the controller&lt;br /&gt;
* View student team (GET #view)&lt;br /&gt;
* Edit team (GET #edit)&lt;br /&gt;
* Create team with valid name (POST #create)&lt;br /&gt;
* Create team with name in use (POST #create)&lt;br /&gt;
* Update valid team name (POST #update) &lt;br /&gt;
* Update team name in use (POST #update)&lt;br /&gt;
* Update with current team name (POST #update)&lt;br /&gt;
* Advertise (GET #advertise)&lt;br /&gt;
''This is currently commented out in the committed code. It seems like the method is never called. It raises missing template error upon every call. ''&lt;br /&gt;
The &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; method was previously named advertise_for_partners, but renamed due to ambiguity as there is another class with the same name. &lt;br /&gt;
&lt;br /&gt;
* Remove advertisement (GET #remove_advertisement )&lt;br /&gt;
The &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; method was previously named remove, but renamed to avoid ambiguity&lt;br /&gt;
This method is never called as well, but it is functional as it do not require any template.&lt;br /&gt;
* Leave student team (GET #leave)&lt;br /&gt;
''This is currently commented out in the committed code, because it will raise error every time when called.''&lt;br /&gt;
It seems like problem happens on &lt;br /&gt;
  line 96: other_members = TeamsUser.where( ['team_id = ?', params[:team_id]]).first&lt;br /&gt;
  line 97: if other_members.length == 0&lt;br /&gt;
This will raise error due to the calling length of other_members, which is a single object but not an array.&lt;br /&gt;
Also, the related record seems to be remain undeleted in the database.&lt;br /&gt;
&lt;br /&gt;
====teams_controller====&lt;br /&gt;
Current test cases are as following.&lt;br /&gt;
* Create team should increase the number of teams by 1(GET #create)&lt;br /&gt;
* Create team should increase the number of team nodes by 1(GET #create)&lt;br /&gt;
* Create team with existing name (POST #create)&lt;br /&gt;
* Create team should redirect to list assignments (POST #create)&lt;br /&gt;
* Delete all teams (GET #delete_all)&lt;br /&gt;
* Delete all teams should redirect to list (GET #delete_all)&lt;br /&gt;
* List should receive assignment (GET #list)&lt;br /&gt;
* List should receive course (GET #list)&lt;br /&gt;
* New should assign parent (GET #new)&lt;br /&gt;
* Update team should redirect (POST #update)&lt;br /&gt;
* Update team should have validate name (POST #update)&lt;br /&gt;
* Edit team should have time (POST #edit)&lt;br /&gt;
* Delete team should redirect (POST #delete)&lt;br /&gt;
* Delete team should decrease the number of teams by 1(GET #delete)&lt;br /&gt;
* Delete team should decrease the number of team nodes by 1(GET #delete)&lt;br /&gt;
* Inherit team should redirect (POST #inherit)&lt;br /&gt;
* Bequeath team should redirect (POST #bequeath)&lt;br /&gt;
The methods in the following are ignored in testing since they are never used in current codes.&lt;br /&gt;
* create_teams_view&lt;br /&gt;
* create_teams&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not. &lt;br /&gt;
&lt;br /&gt;
==Result==&lt;br /&gt;
&lt;br /&gt;
In this section, we will show the result form SimpleCov. The coverage is 24.08%.&lt;br /&gt;
&lt;br /&gt;
[[File:Result.png]]&lt;br /&gt;
&lt;br /&gt;
==Future Works==&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
''Please note that this bug was reported fixed in the newest version of master branch of expertiza, but the fix came too late''&lt;br /&gt;
&lt;br /&gt;
There are several error raised from ''leave'' method need to be fixed, as mentioned above. Future teams may need to add tests on it as soon as it fixed, since it is a crucial functionality of the student team. &lt;br /&gt;
&lt;br /&gt;
Also, methods that seems like not being used, such as &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; may need to be double checked and see if they are redundant.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
* http://guides.rubyonrails.org/testing.html&lt;br /&gt;
* https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84242</id>
		<title>CSC/ECE 517 Spring 2014/oss E1406 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84242"/>
		<updated>2014-04-01T02:47:51Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1406: Improve tests &amp;amp; investigate regex warnings for team functionality=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/controllers/teams_controller.rb ===&lt;br /&gt;
 &lt;br /&gt;
teams_controller contains functionalities for team management for instructor/TA accounts. &lt;br /&gt;
Instructor/TA can:&lt;br /&gt;
* view current teams&lt;br /&gt;
* create new teams&lt;br /&gt;
* import/export teams&lt;br /&gt;
* delete all teams/delete specified team&lt;br /&gt;
* copy existing teams from a course down to an assignment(inherit)&lt;br /&gt;
* update team's information&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/student_team_controller.rb ===&lt;br /&gt;
The student_team_controller support team management for student account.&lt;br /&gt;
student can&lt;br /&gt;
* create team&lt;br /&gt;
* view current team (including team invitations received and sent)&lt;br /&gt;
* advertise for their team&lt;br /&gt;
* remove the advertise for their team&lt;br /&gt;
* leave the team&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
There were no functional tests written on the two controllers to detect bugs, as well as confirming they are functional by itself and after integration.&lt;br /&gt;
&lt;br /&gt;
Our goal is to add comprehensive functional tests and integration tests to the two controllers to provide a preferable test suite for the future developers. &lt;br /&gt;
&lt;br /&gt;
Also, as the classes are influenced by the changes from other, we are also responsible for fixing some of the bugs, refactoring the method names to a better ones, as well as reporting the bugs found in the testing process.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
Overall: contribute to the code coverage, ideally having overall coverage increase 2%&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
* def advertise_for_partners  # change to “advertise”&lt;br /&gt;
* def remove # change to “remove_advertisment”&lt;br /&gt;
* def review # remove this method&lt;br /&gt;
&lt;br /&gt;
===teams_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
&lt;br /&gt;
== Deployment ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/functional/student_team_controller.rb&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/teams_controller&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
;Total Number of Tests : 37&lt;br /&gt;
;Previous Coverage : 22.32%&lt;br /&gt;
;Current Coverage : 24.08% &lt;br /&gt;
&lt;br /&gt;
===Testing Scenarios===&lt;br /&gt;
====student_team_controller====&lt;br /&gt;
Most of the test case are straightforward. There are some of the test cases was commented out due to bug in the controller&lt;br /&gt;
* View student team (GET #view)&lt;br /&gt;
* Edit team (GET #edit)&lt;br /&gt;
* Create team with valid name (POST #create)&lt;br /&gt;
* Create team with name in use (POST #create)&lt;br /&gt;
* Update valid team name (POST #update) &lt;br /&gt;
* Update team name in use (POST #update)&lt;br /&gt;
* Update with current team name (POST #update)&lt;br /&gt;
* Advertise (GET #advertise)&lt;br /&gt;
''This is currently commented out in the committed code. It seems like the method is never called. It raises missing template error upon every call. ''&lt;br /&gt;
The &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; method was previously named advertise_for_partners, but renamed due to ambiguity as there is another class with the same name. &lt;br /&gt;
&lt;br /&gt;
* Remove advertisement (GET #remove_advertisement )&lt;br /&gt;
The &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; method was previously named remove, but renamed to avoid ambiguity&lt;br /&gt;
This method is never called as well, but it is functional as it do not require any template.&lt;br /&gt;
* Leave student team (GET #leave)&lt;br /&gt;
''This is currently commented out in the committed code, because it will raise error every time when called.''&lt;br /&gt;
It seems like problem happens on &lt;br /&gt;
  line 96: other_members = TeamsUser.where( ['team_id = ?', params[:team_id]]).first&lt;br /&gt;
  line 97: if other_members.length == 0&lt;br /&gt;
This will raise error due to the calling length of other_members, which is a single object but not an array.&lt;br /&gt;
Also, the related record seems to be remain undeleted in the database.&lt;br /&gt;
&lt;br /&gt;
====teams_controller====&lt;br /&gt;
Current test cases are as following.&lt;br /&gt;
* Create team should increase the number of teams by 1(GET #create)&lt;br /&gt;
* Create team should increase the number of team nodes by 1(GET #create)&lt;br /&gt;
* Create team with existing name (POST #create)&lt;br /&gt;
* Create team should redirect to list assignments (POST #create)&lt;br /&gt;
* Delete all teams (GET #delete_all)&lt;br /&gt;
* Delete all teams should redirect to list (GET #delete_all)&lt;br /&gt;
* List should receive assignment (GET #list)&lt;br /&gt;
* List should receive course (GET #list)&lt;br /&gt;
* New should assign parent (GET #new)&lt;br /&gt;
* Update team should redirect (POST #update)&lt;br /&gt;
* Update team should have validate name (POST #update)&lt;br /&gt;
* Edit team should have time (POST #edit)&lt;br /&gt;
* Delete team should redirect (POST #delete)&lt;br /&gt;
* Delete team should decrease the number of teams by 1(GET #delete)&lt;br /&gt;
* Delete team should decrease the number of team nodes by 1(GET #delete)&lt;br /&gt;
* Inherit team should redirect (POST #inherit)&lt;br /&gt;
* Bequeath team should redirect (POST #bequeath)&lt;br /&gt;
The methods in the following are ignored in testing since they are never used in current codes.&lt;br /&gt;
* create_teams_view&lt;br /&gt;
* create_teams&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not. &lt;br /&gt;
&lt;br /&gt;
==Result==&lt;br /&gt;
&lt;br /&gt;
In this section, we will show the result form SimpleCov. The coverage is 24.08%.&lt;br /&gt;
&lt;br /&gt;
[[File:Result.png]]&lt;br /&gt;
&lt;br /&gt;
==Future Works==&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
''Please note that this bug was reported fixed in the newest version of master branch of expertiza, but the fix came too late''&lt;br /&gt;
&lt;br /&gt;
There are several error raised from ''leave'' method need to be fixed, as mentioned above. Future teams may need to add tests on it as soon as it fixed, since it is a crucial functionality of the student team. &lt;br /&gt;
&lt;br /&gt;
Also, methods that seems like not being used, such as &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; may need to be double checked and see if they are redundant.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
http://guides.rubyonrails.org/testing.html&lt;br /&gt;
https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84241</id>
		<title>CSC/ECE 517 Spring 2014/oss E1406 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84241"/>
		<updated>2014-04-01T02:45:51Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1406: Improve tests &amp;amp; investigate regex warnings for team functionality=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/controllers/teams_controller.rb ===&lt;br /&gt;
 &lt;br /&gt;
teams_controller contains functionalities for team management for instructor/TA accounts. &lt;br /&gt;
Instructor/TA can:&lt;br /&gt;
* view current teams&lt;br /&gt;
* create new teams&lt;br /&gt;
* import/export teams&lt;br /&gt;
* delete all teams/delete specified team&lt;br /&gt;
* copy existing teams from a course down to an assignment(inherit)&lt;br /&gt;
* update team's information&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/student_team_controller.rb ===&lt;br /&gt;
The student_team_controller support team management for student account.&lt;br /&gt;
student can&lt;br /&gt;
* create team&lt;br /&gt;
* view current team (including team invitations received and sent)&lt;br /&gt;
* advertise for their team&lt;br /&gt;
* remove the advertise for their team&lt;br /&gt;
* leave the team&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
There were no functional tests written on the two controllers to detect bugs, as well as confirming they are functional by itself and after integration.&lt;br /&gt;
&lt;br /&gt;
Our goal is to add comprehensive functional tests and integration tests to the two controllers to provide a preferable test suite for the future developers. &lt;br /&gt;
&lt;br /&gt;
Also, as the classes are influenced by the changes from other, we are also responsible for fixing some of the bugs, refactoring the method names to a better ones, as well as reporting the bugs found in the testing process.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
Overall: contribute to the code coverage, ideally having overall coverage increase 2%&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
* def advertise_for_partners  # change to “advertise”&lt;br /&gt;
* def remove # change to “remove_advertisment”&lt;br /&gt;
* def review # remove this method&lt;br /&gt;
&lt;br /&gt;
===teams_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
&lt;br /&gt;
== Deployment ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/functional/student_team_controller.rb&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/teams_controller&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
;Total Number of Tests : 37&lt;br /&gt;
;Previous Coverage : 22.32%&lt;br /&gt;
;Current Coverage : 24.08% &lt;br /&gt;
&lt;br /&gt;
===Testing Scenarios===&lt;br /&gt;
====student_team_controller====&lt;br /&gt;
Most of the test case are straightforward. There are some of the test cases was commented out due to bug in the controller&lt;br /&gt;
* View student team (GET #view)&lt;br /&gt;
* Edit team (GET #edit)&lt;br /&gt;
* Create team with valid name (POST #create)&lt;br /&gt;
* Create team with name in use (POST #create)&lt;br /&gt;
* Update valid team name (POST #update) &lt;br /&gt;
* Update team name in use (POST #update)&lt;br /&gt;
* Update with current team name (POST #update)&lt;br /&gt;
* Advertise (GET #advertise)&lt;br /&gt;
''This is currently commented out in the committed code. It seems like the method is never called. It raises missing template error upon every call. ''&lt;br /&gt;
The &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; method was previously named advertise_for_partners, but renamed due to ambiguity as there is another class with the same name. &lt;br /&gt;
&lt;br /&gt;
* Remove advertisement (GET #remove_advertisement )&lt;br /&gt;
The &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; method was previously named remove, but renamed to avoid ambiguity&lt;br /&gt;
This method is never called as well, but it is functional as it do not require any template.&lt;br /&gt;
* Leave student team (GET #leave)&lt;br /&gt;
''This is currently commented out in the committed code, because it will raise error every time when called.''&lt;br /&gt;
It seems like problem happens on &lt;br /&gt;
  line 96: other_members = TeamsUser.where( ['team_id = ?', params[:team_id]]).first&lt;br /&gt;
  line 97: if other_members.length == 0&lt;br /&gt;
This will raise error due to the calling length of other_members, which is a single object but not an array.&lt;br /&gt;
Also, the related record seems to be remain undeleted in the database.&lt;br /&gt;
&lt;br /&gt;
====teams_controller====&lt;br /&gt;
Current test cases are as following.&lt;br /&gt;
* Create team should increase the number of teams by 1(GET #create)&lt;br /&gt;
* Create team should increase the number of team nodes by 1(GET #create)&lt;br /&gt;
* Create team with existing name (POST #create)&lt;br /&gt;
* Create team should redirect to list assignments (POST #create)&lt;br /&gt;
* Delete all teams (GET #delete_all)&lt;br /&gt;
* Delete all teams should redirect to list (GET #delete_all)&lt;br /&gt;
* List should receive assignment (GET #list)&lt;br /&gt;
* List should receive course (GET #list)&lt;br /&gt;
* New should assign parent (GET #new)&lt;br /&gt;
* Update team should redirect (POST #update)&lt;br /&gt;
* Update team should have validate name (POST #update)&lt;br /&gt;
* Edit team should have time (POST #edit)&lt;br /&gt;
* Delete team should redirect (POST #delete)&lt;br /&gt;
* Delete team should decrease the number of teams by 1(GET #delete)&lt;br /&gt;
* Delete team should decrease the number of team nodes by 1(GET #delete)&lt;br /&gt;
* Inherit team should redirect (POST #inherit)&lt;br /&gt;
* Bequeath team should redirect (POST #bequeath)&lt;br /&gt;
The methods in the following are ignored in testing since they are never used in current codes.&lt;br /&gt;
* create_teams_view&lt;br /&gt;
* create_teams&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not. &lt;br /&gt;
&lt;br /&gt;
==Result==&lt;br /&gt;
&lt;br /&gt;
[[File:Result.png]]&lt;br /&gt;
&lt;br /&gt;
==Future Works==&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
''Please note that this bug was reported fixed in the newest version of master branch of expertiza, but the fix came too late''&lt;br /&gt;
&lt;br /&gt;
There are several error raised from ''leave'' method need to be fixed, as mentioned above. Future teams may need to add tests on it as soon as it fixed, since it is a crucial functionality of the student team. &lt;br /&gt;
&lt;br /&gt;
Also, methods that seems like not being used, such as &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; may need to be double checked and see if they are redundant.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
http://guides.rubyonrails.org/testing.html&lt;br /&gt;
https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Result.png&amp;diff=84240</id>
		<title>File:Result.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Result.png&amp;diff=84240"/>
		<updated>2014-04-01T02:44:30Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: SimpleCov result&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;SimpleCov result&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84234</id>
		<title>CSC/ECE 517 Spring 2014/oss E1406 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84234"/>
		<updated>2014-04-01T02:00:51Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1406: Improve tests &amp;amp; investigate regex warnings for team functionality=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/controllers/teams_controller.rb ===&lt;br /&gt;
 &lt;br /&gt;
teams_controller contains functionalities for team management for instructor/TA accounts. &lt;br /&gt;
Instructor/TA can:&lt;br /&gt;
* view current teams&lt;br /&gt;
* create new teams&lt;br /&gt;
* import/export teams&lt;br /&gt;
* delete all teams/delete specified team&lt;br /&gt;
* copy existing teams from a course down to an assignment(inherit)&lt;br /&gt;
* update team's information&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/student_team_controller.rb ===&lt;br /&gt;
The student_team_controller support team management for student account.&lt;br /&gt;
student can&lt;br /&gt;
* create team&lt;br /&gt;
* view current team (including team invitations received and sent)&lt;br /&gt;
* advertise for their team&lt;br /&gt;
* remove the advertise for their team&lt;br /&gt;
* leave the team&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
There were no functional tests written on the two controllers to detect bugs, as well as confirming they are functional by itself and after integration.&lt;br /&gt;
&lt;br /&gt;
Our goal is to add comprehensive functional tests and integration tests to the two controllers to provide a preferable test suite for the future developers. &lt;br /&gt;
&lt;br /&gt;
Also, as the classes are influenced by the changes from other, we are also responsible for fixing some of the bugs, refactoring the method names to a better ones, as well as reporting the bugs found in the testing process.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
Overall: contribute to the code coverage, ideally having overall coverage increase 2%&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
* def advertise_for_partners  # change to “advertise”&lt;br /&gt;
* def remove # change to “remove_advertisment”&lt;br /&gt;
* def review # remove this method&lt;br /&gt;
&lt;br /&gt;
===teams_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
&lt;br /&gt;
== Deployment ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/functional/student_team_controller.rb&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/teams_controller&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
;Total Number of Tests : 37&lt;br /&gt;
;Previous Coverage : 22.32%&lt;br /&gt;
;Current Coverage : 24.08% &lt;br /&gt;
&lt;br /&gt;
===Testing Scenarios===&lt;br /&gt;
====student_team_controller====&lt;br /&gt;
Most of the test case are straightforward. There are some of the test cases was commented out due to bug in the controller&lt;br /&gt;
* View student team (GET #view)&lt;br /&gt;
* Edit team (GET #edit)&lt;br /&gt;
* Create team with valid name (POST #create)&lt;br /&gt;
* Create team with name in use (POST #create)&lt;br /&gt;
* Update valid team name (POST #update) &lt;br /&gt;
* Update team name in use (POST #update)&lt;br /&gt;
* Update with current team name (POST #update)&lt;br /&gt;
* Advertise (GET #advertise)&lt;br /&gt;
''This is currently commented out in the committed code. It seems like the method is never called. It raises missing template error upon every call. ''&lt;br /&gt;
The &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; method was previously named advertise_for_partners, but renamed due to ambiguity as there is another class with the same name. &lt;br /&gt;
&lt;br /&gt;
* Remove advertisement (GET #remove_advertisement )&lt;br /&gt;
The &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; method was previously named remove, but renamed to avoid ambiguity&lt;br /&gt;
This method is never called as well, but it is functional as it do not require any template.&lt;br /&gt;
* Leave student team (GET #leave)&lt;br /&gt;
''This is currently commented out in the committed code, because it will raise error every time when called.''&lt;br /&gt;
It seems like problem happens on &lt;br /&gt;
  line 96: other_members = TeamsUser.where( ['team_id = ?', params[:team_id]]).first&lt;br /&gt;
  line 97: if other_members.length == 0&lt;br /&gt;
This will raise error due to the calling length of other_members, which is a single object but not an array.&lt;br /&gt;
Also, the related record seems to be remain undeleted in the database.&lt;br /&gt;
&lt;br /&gt;
====teams_controller====&lt;br /&gt;
Current test cases are as following.&lt;br /&gt;
* Create team should increase the number of teams by 1(GET #create)&lt;br /&gt;
* Create team should increase the number of team nodes by 1(GET #create)&lt;br /&gt;
* Create team with existing name (POST #create)&lt;br /&gt;
* Create team should redirect to list assignments (POST #create)&lt;br /&gt;
* Delete all teams (GET #delete_all)&lt;br /&gt;
* Delete all teams should redirect to list (GET #delete_all)&lt;br /&gt;
* List should receive assignment (GET #list)&lt;br /&gt;
* List should receive course (GET #list)&lt;br /&gt;
* New should assign parent (GET #new)&lt;br /&gt;
* Update team should redirect (POST #update)&lt;br /&gt;
* Update team should have validate name (POST #update)&lt;br /&gt;
* Edit team should have time (POST #edit)&lt;br /&gt;
* Delete team should redirect (POST #delete)&lt;br /&gt;
* Delete team should decrease the number of teams by 1(GET #delete)&lt;br /&gt;
* Delete team should decrease the number of team nodes by 1(GET #delete)&lt;br /&gt;
* Inherit team should redirect (POST #inherit)&lt;br /&gt;
* Bequeath team should redirect (POST #bequeath)&lt;br /&gt;
The methods in the following are ignored in testing since they are never used in current codes.&lt;br /&gt;
* create_teams_view&lt;br /&gt;
* create_teams&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not. &lt;br /&gt;
&lt;br /&gt;
==Future Works==&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
''Please note that this bug was reported fixed in the newest version of master branch of expertiza, but the fix came too late''&lt;br /&gt;
&lt;br /&gt;
There are several error raised from ''leave'' method need to be fixed, as mentioned above. Future teams may need to add tests on it as soon as it fixed, since it is a crucial functionality of the student team. &lt;br /&gt;
&lt;br /&gt;
Also, methods that seems like not being used, such as &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; may need to be double checked and see if they are redundant.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
http://guides.rubyonrails.org/testing.html&lt;br /&gt;
https://github.com/colszowka/simplecov&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84233</id>
		<title>CSC/ECE 517 Spring 2014/oss E1406 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84233"/>
		<updated>2014-04-01T01:58:20Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1406: Improve tests &amp;amp; investigate regex warnings for team functionality=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/controllers/teams_controller.rb ===&lt;br /&gt;
 &lt;br /&gt;
teams_controller contains functionalities for team management for instructor/TA accounts. &lt;br /&gt;
Instructor/TA can:&lt;br /&gt;
* view current teams&lt;br /&gt;
* create new teams&lt;br /&gt;
* import/export teams&lt;br /&gt;
* delete all teams/delete specified team&lt;br /&gt;
* copy existing teams from a course down to an assignment(inherit)&lt;br /&gt;
* update team's information&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/student_team_controller.rb ===&lt;br /&gt;
The student_team_controller support team management for student account.&lt;br /&gt;
student can&lt;br /&gt;
* create team&lt;br /&gt;
* view current team (including team invitations received and sent)&lt;br /&gt;
* advertise for their team&lt;br /&gt;
* remove the advertise for their team&lt;br /&gt;
* leave the team&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
There were no functional tests written on the two controllers to detect bugs, as well as confirming they are functional by itself and after integration.&lt;br /&gt;
&lt;br /&gt;
Our goal is to add comprehensive functional tests and integration tests to the two controllers to provide a preferable test suite for the future developers. &lt;br /&gt;
&lt;br /&gt;
Also, as the classes are influenced by the changes from other, we are also responsible for fixing some of the bugs, refactoring the method names to a better ones, as well as reporting the bugs found in the testing process.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
Overall: contribute to the code coverage, ideally having overall coverage increase 2%&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
* def advertise_for_partners  # change to “advertise”&lt;br /&gt;
* def remove # change to “remove_advertisment”&lt;br /&gt;
* def review # remove this method&lt;br /&gt;
&lt;br /&gt;
===teams_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
&lt;br /&gt;
== Deployment ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/functional/student_team_controller.rb&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/teams_controller&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
;Total Number of Tests : 37&lt;br /&gt;
;Previous Coverage : 22.32%&lt;br /&gt;
;Current Coverage : 24.08% &lt;br /&gt;
&lt;br /&gt;
===Testing Scenarios===&lt;br /&gt;
====student_team_controller====&lt;br /&gt;
Most of the test case are straightforward. There are some of the test cases was commented out due to bug in the controller&lt;br /&gt;
* View student team (GET #view)&lt;br /&gt;
* Edit team (GET #edit)&lt;br /&gt;
* Create team with valid name (POST #create)&lt;br /&gt;
* Create team with name in use (POST #create)&lt;br /&gt;
* Update valid team name (POST #update) &lt;br /&gt;
* Update team name in use (POST #update)&lt;br /&gt;
* Update with current team name (POST #update)&lt;br /&gt;
* Advertise (GET #advertise)&lt;br /&gt;
''This is currently commented out in the committed code. It seems like the method is never called. It raises missing template error upon every call. ''&lt;br /&gt;
The &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; method was previously named advertise_for_partners, but renamed due to ambiguity as there is another class with the same name. &lt;br /&gt;
&lt;br /&gt;
* Remove advertisement (GET #remove_advertisement )&lt;br /&gt;
The &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; method was previously named remove, but renamed to avoid ambiguity&lt;br /&gt;
This method is never called as well, but it is functional as it do not require any template.&lt;br /&gt;
* Leave student team (GET #leave)&lt;br /&gt;
''This is currently commented out in the committed code, because it will raise error every time when called.''&lt;br /&gt;
It seems like problem happens on &lt;br /&gt;
  line 96: other_members = TeamsUser.where( ['team_id = ?', params[:team_id]]).first&lt;br /&gt;
  line 97: if other_members.length == 0&lt;br /&gt;
This will raise error due to the calling length of other_members, which is a single object but not an array.&lt;br /&gt;
Also, the related record seems to be remain undeleted in the database.&lt;br /&gt;
&lt;br /&gt;
====teams_controller====&lt;br /&gt;
Current test cases are as following.&lt;br /&gt;
* Create team should increase the number of teams by 1(GET #create)&lt;br /&gt;
* Create team should increase the number of team nodes by 1(GET #create)&lt;br /&gt;
* Create team with existing name (POST #create)&lt;br /&gt;
* Create team should redirect to list assignments (POST #create)&lt;br /&gt;
* Delete all teams (GET #delete_all)&lt;br /&gt;
* Delete all teams should redirect to list (GET #delete_all)&lt;br /&gt;
* List should receive assignment (GET #list)&lt;br /&gt;
* List should receive course (GET #list)&lt;br /&gt;
* New should assign parent (GET #new)&lt;br /&gt;
* Update team should redirect (POST #update)&lt;br /&gt;
* Update team should have validate name (POST #update)&lt;br /&gt;
* Edit team should have time (POST #edit)&lt;br /&gt;
* Delete team should redirect (POST #delete)&lt;br /&gt;
* Delete team should decrease the number of teams by 1(GET #delete)&lt;br /&gt;
* Delete team should decrease the number of team nodes by 1(GET #delete)&lt;br /&gt;
* Inherit team should redirect (POST #inherit)&lt;br /&gt;
* Bequeath team should redirect (POST #bequeath)&lt;br /&gt;
The methods in the following are ignored in testing since they are never used in current codes.&lt;br /&gt;
* create_teams_view&lt;br /&gt;
* create_teams&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not. &lt;br /&gt;
&lt;br /&gt;
==Future Works==&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
''Please note that this bug was reported fixed in the newest version of master branch of expertiza, but the fix came too late''&lt;br /&gt;
&lt;br /&gt;
There are several error raised from ''leave'' method need to be fixed, as mentioned above. Future teams may need to add tests on it as soon as it fixed, since it is a crucial functionality of the student team. &lt;br /&gt;
&lt;br /&gt;
Also, methods that seems like not being used, such as &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; may need to be double checked and see if they are redundant.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
http://guides.rubyonrails.org/testing.html&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84232</id>
		<title>CSC/ECE 517 Spring 2014/oss E1406 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84232"/>
		<updated>2014-04-01T01:56:39Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1406: Improve tests &amp;amp; investigate regex warnings for team functionality=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/controllers/teams_controller.rb ===&lt;br /&gt;
 &lt;br /&gt;
teams_controller contains functionalities for team management for instructor/TA accounts. &lt;br /&gt;
Instructor/TA can:&lt;br /&gt;
* view current teams&lt;br /&gt;
* create new teams&lt;br /&gt;
* import/export teams&lt;br /&gt;
* delete all teams/delete specified team&lt;br /&gt;
* copy existing teams from a course down to an assignment(inherit)&lt;br /&gt;
* update team's information&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/student_team_controller.rb ===&lt;br /&gt;
The student_team_controller support team management for student account.&lt;br /&gt;
student can&lt;br /&gt;
* create team&lt;br /&gt;
* view current team (including team invitations received and sent)&lt;br /&gt;
* advertise for their team&lt;br /&gt;
* remove the advertise for their team&lt;br /&gt;
* leave the team&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
There were no functional tests written on the two controllers to detect bugs, as well as confirming they are functional by itself and after integration.&lt;br /&gt;
&lt;br /&gt;
Our goal is to add comprehensive functional tests and integration tests to the two controllers to provide a preferable test suite for the future developers. &lt;br /&gt;
&lt;br /&gt;
Also, as the classes are influenced by the changes from other, we are also responsible for fixing some of the bugs, refactoring the method names to a better ones, as well as reporting the bugs found in the testing process.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
Overall: contribute to the code coverage, ideally having overall coverage increase 2%&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
* def advertise_for_partners  # change to “advertise”&lt;br /&gt;
* def remove # change to “remove_advertisment”&lt;br /&gt;
* def review # remove this method&lt;br /&gt;
&lt;br /&gt;
===teams_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
&lt;br /&gt;
== Deployment ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/functional/student_team_controller.rb&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/teams_controller&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
;Total Number of Tests : 37&lt;br /&gt;
;Previous Coverage : 22.32%&lt;br /&gt;
;Current Coverage : 24.08% &lt;br /&gt;
&lt;br /&gt;
===Testing Scenarios===&lt;br /&gt;
====student_team_controller====&lt;br /&gt;
Most of the test case are straightforward. There are some of the test cases was commented out due to bug in the controller&lt;br /&gt;
* View student team (GET #view)&lt;br /&gt;
* Edit team (GET #edit)&lt;br /&gt;
* Create team with valid name (POST #create)&lt;br /&gt;
* Create team with name in use (POST #create)&lt;br /&gt;
* Update valid team name (POST #update) &lt;br /&gt;
* Update team name in use (POST #update)&lt;br /&gt;
* Update with current team name (POST #update)&lt;br /&gt;
* Advertise (GET #advertise)&lt;br /&gt;
''This is currently commented out in the committed code. It seems like the method is never called. It raises missing template error upon every call. ''&lt;br /&gt;
The &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; method was previously named advertise_for_partners, but renamed due to ambiguity as there is another class with the same name. &lt;br /&gt;
&lt;br /&gt;
* Remove advertisement (GET #remove_advertisement )&lt;br /&gt;
The &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; method was previously named remove, but renamed to avoid ambiguity&lt;br /&gt;
This method is never called as well, but it is functional as it do not require any template.&lt;br /&gt;
* Leave student team (GET #leave)&lt;br /&gt;
''This is currently commented out in the committed code, because it will raise error every time when called.''&lt;br /&gt;
It seems like problem happens on &lt;br /&gt;
  line 96: other_members = TeamsUser.where( ['team_id = ?', params[:team_id]]).first&lt;br /&gt;
  line 97: if other_members.length == 0&lt;br /&gt;
This will raise error due to the calling length of other_members, which is a single object but not an array.&lt;br /&gt;
Also, the related record seems to be remain undeleted in the database.&lt;br /&gt;
&lt;br /&gt;
====teams_controller====&lt;br /&gt;
Current test cases are as following.&lt;br /&gt;
* Create team should increase the number of teams by 1(GET #create)&lt;br /&gt;
* Create team should increase the number of team nodes by 1(GET #create)&lt;br /&gt;
* Create team with existing name (POST #create)&lt;br /&gt;
* Create team should redirect to list assignments (POST #create)&lt;br /&gt;
* Delete all teams (GET #delete_all)&lt;br /&gt;
* Delete all teams should redirect to list (GET #delete_all)&lt;br /&gt;
* List should receive assignment (GET #list)&lt;br /&gt;
* List should receive course (GET #list)&lt;br /&gt;
* New should assign parent (GET #new)&lt;br /&gt;
* Update team should redirect (POST #update)&lt;br /&gt;
* Update team should have validate name (POST #update)&lt;br /&gt;
* Edit team should have time (POST #edit)&lt;br /&gt;
* Delete team should redirect (POST #delete)&lt;br /&gt;
* Delete team should decrease the number of teams by 1(GET #delete)&lt;br /&gt;
* Delete team should decrease the number of team nodes by 1(GET #delete)&lt;br /&gt;
* Inherit team should redirect (POST #inherit)&lt;br /&gt;
* Bequeath team should redirect (POST #bequeath)&lt;br /&gt;
The methods in the following are ignored in testing since they are never used in current codes.&lt;br /&gt;
* create_teams_view&lt;br /&gt;
* create_teams&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not. &lt;br /&gt;
&lt;br /&gt;
==Future Works==&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
''Please note that this bug was reported fixed in the newest version of master branch of expertiza, but the fix came too late''&lt;br /&gt;
&lt;br /&gt;
There are several error raised from ''leave'' method need to be fixed, as mentioned above. Future teams may need to add tests on it as soon as it fixed, since it is a crucial functionality of the student team. &lt;br /&gt;
&lt;br /&gt;
Also, methods that seems like not being used, such as &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; may need to be double checked and see if they are redundant.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84223</id>
		<title>CSC/ECE 517 Spring 2014/oss E1406 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84223"/>
		<updated>2014-04-01T01:20:03Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1406: Improve tests &amp;amp; investigate regex warnings for team functionality=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/controllers/teams_controller.rb ===&lt;br /&gt;
 &lt;br /&gt;
teams_controller contains functionalities for team management for instructor/TA accounts. &lt;br /&gt;
Instructor/TA can:&lt;br /&gt;
* view current teams&lt;br /&gt;
* create new teams&lt;br /&gt;
* import/export teams&lt;br /&gt;
* delete all teams/delete specified team&lt;br /&gt;
* copy existing teams from a course down to an assignment(inherit)&lt;br /&gt;
* update team's information&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/student_team_controller.rb ===&lt;br /&gt;
The student_team_controller support team management for student account.&lt;br /&gt;
student can&lt;br /&gt;
* create team&lt;br /&gt;
* view current team (including team invitations received and sent)&lt;br /&gt;
* advertise for their team&lt;br /&gt;
* remove the advertise for their team&lt;br /&gt;
* leave the team&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
There were no functional tests written on the two controllers to detect bugs, as well as confirming they are functional by itself and after integration.&lt;br /&gt;
&lt;br /&gt;
Our goal is to add comprehensive functional tests and integration tests to the two controllers to provide a preferable test suite for the future developers. &lt;br /&gt;
&lt;br /&gt;
Also, as the classes are influenced by the changes from other, we are also responsible for fixing some of the bugs, refactoring the method names to a better ones, as well as reporting the bugs found in the testing process.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
Overall: contribute to the code coverage, ideally having overall coverage increase 2%&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
* def advertise_for_partners  # change to “advertise”&lt;br /&gt;
* def remove # change to “remove_advertisment”&lt;br /&gt;
* def review # remove this method&lt;br /&gt;
&lt;br /&gt;
===teams_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
&lt;br /&gt;
== Deployment ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/functional/student_team_controller.rb&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/teams_controller&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
;Total Number of Tests : 37&lt;br /&gt;
;Previous Coverage : 22.32%&lt;br /&gt;
;Current Coverage : 24.08% &lt;br /&gt;
&lt;br /&gt;
===Testing Scenarios===&lt;br /&gt;
====student_team_controller====&lt;br /&gt;
Most of the test case are straightforward. There are some of the test cases was commented out due to bug in the controller&lt;br /&gt;
* View student team (GET #view)&lt;br /&gt;
* Edit team (GET #edit)&lt;br /&gt;
* Create team with valid name (POST #create)&lt;br /&gt;
* Create team with name in use (POST #create)&lt;br /&gt;
* Update valid team name (POST #update) &lt;br /&gt;
* Update team name in use (POST #update)&lt;br /&gt;
* Update with current team name (POST #update)&lt;br /&gt;
* Advertise (GET #advertise)&lt;br /&gt;
''This is currently commented out in the committed code. It seems like the method is never called. It raises missing template error upon every call. ''&lt;br /&gt;
The &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; method was previously named advertise_for_partners, but renamed due to ambiguity as there is another class with the same name. &lt;br /&gt;
&lt;br /&gt;
* Remove advertisement (GET #remove_advertisement )&lt;br /&gt;
The &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; method was previously named remove, but renamed to avoid ambiguity&lt;br /&gt;
This method is never called as well, but it is functional as it do not require any template.&lt;br /&gt;
* Leave student team (GET #leave)&lt;br /&gt;
''This is currently commented out in the committed code, because it will raise error every time when called.''&lt;br /&gt;
It seems like problem happens on &lt;br /&gt;
  line 96: other_members = TeamsUser.where( ['team_id = ?', params[:team_id]]).first&lt;br /&gt;
  line 97: if other_members.length == 0&lt;br /&gt;
This will raise error due to the calling length of other_members, which is a single object but not an array.&lt;br /&gt;
Also, the related record seems to be remain undeleted in the database.&lt;br /&gt;
&lt;br /&gt;
====teams_controller====&lt;br /&gt;
Current test cases are as following.&lt;br /&gt;
* Create team should increase the number of teams by 1(GET #create)&lt;br /&gt;
* Create team should increase the number of team nodes by 1(GET #create)&lt;br /&gt;
* Create team with existing name (POST #create)&lt;br /&gt;
* Create team should redirect to list assignments (POST #create)&lt;br /&gt;
* Delete all teams (GET #delete_all)&lt;br /&gt;
* Delete all teams should redirect to list (GET #delete_all)&lt;br /&gt;
* List should receive assignment (GET #list)&lt;br /&gt;
* List should receive course (GET #list)&lt;br /&gt;
* New should assign parent (GET #new)&lt;br /&gt;
* Update team should redirect (POST #update)&lt;br /&gt;
* Update team should have validate name (POST #update)&lt;br /&gt;
* Edit team should have time (POST #edit)&lt;br /&gt;
* Delete team should redirect (POST #delete)&lt;br /&gt;
* Delete team should decrease the number of teams by 1(GET #delete)&lt;br /&gt;
* Delete team should decrease the number of team nodes by 1(GET #delete)&lt;br /&gt;
* Inherit team should redirect (POST #inherit)&lt;br /&gt;
* Bequeath team should redirect (POST #bequeath)&lt;br /&gt;
The methods in the following are ignored in testing since they are never used in current codes.&lt;br /&gt;
* create_teams_view&lt;br /&gt;
* create_teams&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not. &lt;br /&gt;
[[File:result.png]]&lt;br /&gt;
==Future Works==&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
''Please note that this bug was reported fixed in the newest version of master branch of expertiza, but the fix came too late''&lt;br /&gt;
&lt;br /&gt;
There are several error raised from ''leave'' method need to be fixed, as mentioned above. Future teams may need to add tests on it as soon as it fixed, since it is a crucial functionality of the student team. &lt;br /&gt;
&lt;br /&gt;
Also, methods that seems like not being used, such as &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; may need to be double checked and see if they are redundant.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84221</id>
		<title>CSC/ECE 517 Spring 2014/oss E1406 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84221"/>
		<updated>2014-04-01T01:10:53Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1406: Improve tests &amp;amp; investigate regex warnings for team functionality=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/controllers/teams_controller.rb ===&lt;br /&gt;
 &lt;br /&gt;
teams_controller contains functionalities for team management for instructor/TA accounts. &lt;br /&gt;
Instructor/TA can:&lt;br /&gt;
* view current teams&lt;br /&gt;
* create new teams&lt;br /&gt;
* import/export teams&lt;br /&gt;
* delete all teams/delete specified team&lt;br /&gt;
* copy existing teams from a course down to an assignment(inherit)&lt;br /&gt;
* update team's information&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/student_team_controller.rb ===&lt;br /&gt;
The student_team_controller support team management for student account.&lt;br /&gt;
student can&lt;br /&gt;
* create team&lt;br /&gt;
* view current team (including team invitations received and sent)&lt;br /&gt;
* advertise for their team&lt;br /&gt;
* remove the advertise for their team&lt;br /&gt;
* leave the team&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
There were no functional tests written on the two controllers to detect bugs, as well as confirming they are functional by itself and after integration.&lt;br /&gt;
&lt;br /&gt;
Our goal is to add comprehensive functional tests and integration tests to the two controllers to provide a preferable test suite for the future developers. &lt;br /&gt;
&lt;br /&gt;
Also, as the classes are influenced by the changes from other, we are also responsible for fixing some of the bugs, refactoring the method names to a better ones, as well as reporting the bugs found in the testing process.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
Overall: contribute to the code coverage, ideally having overall coverage increase 2%&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
* def advertise_for_partners  # change to “advertise”&lt;br /&gt;
* def remove # change to “remove_advertisment”&lt;br /&gt;
* def review # remove this method&lt;br /&gt;
&lt;br /&gt;
===teams_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
&lt;br /&gt;
== Deployment ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/functional/student_team_controller.rb&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/teams_controller&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
;Total Number of Tests : 37&lt;br /&gt;
;Previous Coverage : 22.32%&lt;br /&gt;
;Current Coverage : 24.08% &lt;br /&gt;
&lt;br /&gt;
===Testing Scenarios===&lt;br /&gt;
====student_team_controller====&lt;br /&gt;
Most of the test case are straightforward. There are some of the test cases was commented out due to bug in the controller&lt;br /&gt;
* View student team (GET #view)&lt;br /&gt;
* Edit team (GET #edit)&lt;br /&gt;
* Create team with valid name (POST #create)&lt;br /&gt;
* Create team with name in use (POST #create)&lt;br /&gt;
* Update valid team name (POST #update) &lt;br /&gt;
* Update team name in use (POST #update)&lt;br /&gt;
* Update with current team name (POST #update)&lt;br /&gt;
* Advertise (GET #advertise)&lt;br /&gt;
''This is currently commented out in the committed code. It seems like the method is never called. It raises missing template error upon every call. ''&lt;br /&gt;
The &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; method was previously named advertise_for_partners, but renamed due to ambiguity as there is another class with the same name. &lt;br /&gt;
&lt;br /&gt;
* Remove advertisement (GET #remove_advertisement )&lt;br /&gt;
The &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; method was previously named remove, but renamed to avoid ambiguity&lt;br /&gt;
This method is never called as well, but it is functional as it do not require any template.&lt;br /&gt;
* Leave student team (GET #leave)&lt;br /&gt;
''This is currently commented out in the committed code, because it will raise error every time when called.''&lt;br /&gt;
It seems like problem happens on &lt;br /&gt;
  line 96: other_members = TeamsUser.where( ['team_id = ?', params[:team_id]]).first&lt;br /&gt;
  line 97: if other_members.length == 0&lt;br /&gt;
This will raise error due to the calling length of other_members, which is a single object but not an array.&lt;br /&gt;
Also, the related record seems to be remain undeleted in the database.&lt;br /&gt;
&lt;br /&gt;
====teams_controller====&lt;br /&gt;
Current test cases are as following.&lt;br /&gt;
* Create team should increase the number of teams by 1(GET #create)&lt;br /&gt;
* Create team should increase the number of team nodes by 1(GET #create)&lt;br /&gt;
* Create team with existing name (POST #create)&lt;br /&gt;
* Create team should redirect to list assignments (POST #create)&lt;br /&gt;
* Delete all teams (GET #delete_all)&lt;br /&gt;
* Delete all teams should redirect to list (GET #delete_all)&lt;br /&gt;
* List should receive assignment (GET #list)&lt;br /&gt;
* List should receive course (GET #list)&lt;br /&gt;
* New should assign parent (GET #new)&lt;br /&gt;
* Update team should redirect (POST #update)&lt;br /&gt;
* Update team should have validate name (POST #update)&lt;br /&gt;
* Edit team should have time (POST #edit)&lt;br /&gt;
* Delete team should redirect (POST #delete)&lt;br /&gt;
* Delete team should decrease the number of teams by 1(GET #delete)&lt;br /&gt;
* Delete team should decrease the number of team nodes by 1(GET #delete)&lt;br /&gt;
* Inherit team should redirect (POST #inherit)&lt;br /&gt;
* Bequeath team should redirect (POST #bequeath)&lt;br /&gt;
The methods in the following are ignored in testing since they are never used in current codes.&lt;br /&gt;
* create_teams_view&lt;br /&gt;
* create_teams&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not. &lt;br /&gt;
&lt;br /&gt;
==Future Works==&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
''Please note that this bug was reported fixed in the newest version of master branch of expertiza, but the fix came too late''&lt;br /&gt;
&lt;br /&gt;
There are several error raised from ''leave'' method need to be fixed, as mentioned above. Future teams may need to add tests on it as soon as it fixed, since it is a crucial functionality of the student team. &lt;br /&gt;
&lt;br /&gt;
Also, methods that seems like not being used, such as &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; may need to be double checked and see if they are redundant.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84220</id>
		<title>CSC/ECE 517 Spring 2014/oss E1406 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84220"/>
		<updated>2014-04-01T01:09:57Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1406: Improve tests &amp;amp; investigate regex warnings for team functionality=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/controllers/teams_controller.rb ===&lt;br /&gt;
 &lt;br /&gt;
teams_controller contains functionalities for team management for instructor/TA accounts. &lt;br /&gt;
Instructor/TA can:&lt;br /&gt;
* view current teams&lt;br /&gt;
* create new teams&lt;br /&gt;
* import/export teams&lt;br /&gt;
* delete all teams/delete specified team&lt;br /&gt;
* copy existing teams from a course down to an assignment(inherit)&lt;br /&gt;
* update team's information&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/student_team_controller.rb ===&lt;br /&gt;
The student_team_controller support team management for student account.&lt;br /&gt;
student can&lt;br /&gt;
* create team&lt;br /&gt;
* view current team (including team invitations received and sent)&lt;br /&gt;
* advertise for their team&lt;br /&gt;
* remove the advertise for their team&lt;br /&gt;
* leave the team&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
There were no functional tests written on the two controllers to detect bugs, as well as confirming they are functional by itself and after integration.&lt;br /&gt;
&lt;br /&gt;
Our goal is to add comprehensive functional tests and integration tests to the two controllers to provide a preferable test suite for the future developers. &lt;br /&gt;
&lt;br /&gt;
Also, as the classes are influenced by the changes from other, we are also responsible for fixing some of the bugs, refactoring the method names to a better ones, as well as reporting the bugs found in the testing process.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
Overall: contribute to the code coverage, ideally having overall coverage increase 2%&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
* def advertise_for_partners  # change to “advertise”&lt;br /&gt;
* def remove # change to “remove_advertisment”&lt;br /&gt;
* def review # remove this method&lt;br /&gt;
&lt;br /&gt;
===teams_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
&lt;br /&gt;
== Deployment ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/functional/student_team_controller.rb&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/teams_controller&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
;Total Number of Tests : 37&lt;br /&gt;
;Previous Coverage : 22.32%&lt;br /&gt;
;Current Coverage : 24.08% &lt;br /&gt;
&lt;br /&gt;
===Testing Scenarios===&lt;br /&gt;
====student_team_controller====&lt;br /&gt;
Most of the test case are straightforward. There are some of the test cases was commented out due to bug in the controller&lt;br /&gt;
* View student team (GET #view)&lt;br /&gt;
* Edit team (GET #edit)&lt;br /&gt;
* Create team with valid name (POST #create)&lt;br /&gt;
* Create team with name in use (POST #create)&lt;br /&gt;
* Update valid team name (POST #update) &lt;br /&gt;
* Update team name in use (POST #update)&lt;br /&gt;
* Update with current team name (POST #update)&lt;br /&gt;
* Advertise (GET #advertise)&lt;br /&gt;
''This is currently commented out in the committed code. It seems like the method is never called. It raises missing template error upon every call. ''&lt;br /&gt;
The &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; method was previously named advertise_for_partners, but renamed due to ambiguity as there is another class with the same name. &lt;br /&gt;
&lt;br /&gt;
* Remove advertisement (GET #remove_advertisement )&lt;br /&gt;
The &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; method was previously named remove, but renamed to avoid ambiguity&lt;br /&gt;
This method is never called as well, but it is functional as it do not require any template.&lt;br /&gt;
* Leave student team (GET #leave)&lt;br /&gt;
''This is currently commented out in the committed code, because it will raise error every time when called.''&lt;br /&gt;
It seems like problem happens on &lt;br /&gt;
  line 96: other_members = TeamsUser.where( ['team_id = ?', params[:team_id]]).first&lt;br /&gt;
  line 97: if other_members.length == 0&lt;br /&gt;
This will raise error due to the calling length of other_members, which is a single object but not an array.&lt;br /&gt;
Also, the related record seems to be remain undeleted in the database.&lt;br /&gt;
&lt;br /&gt;
====teams_controller====&lt;br /&gt;
Current test cases are as following.&lt;br /&gt;
* Create team should increase the number of teams by 1(GET #create)&lt;br /&gt;
* Create team should increase the number of team nodes by 1(GET #create)&lt;br /&gt;
* Create team with existing name (POST #create)&lt;br /&gt;
* Create team should redirect to list assignments (POST #create)&lt;br /&gt;
* Delete all teams (GET #delete_all)&lt;br /&gt;
* Delete all teams should redirect to list (GET #delete_all)&lt;br /&gt;
* List should receive assignment (GET #list)&lt;br /&gt;
* List should receive course (GET #list)&lt;br /&gt;
* New should assign parent (GET #new)&lt;br /&gt;
* Update team should redirect (POST #update)&lt;br /&gt;
* Update team should have validate name (POST #update)&lt;br /&gt;
* Edit team should have time (POST #edit)&lt;br /&gt;
* Delete team should redirect (POST #delete)&lt;br /&gt;
* Delete team should decrease the number of teams by 1(GET #delete)&lt;br /&gt;
* Delete team should decrease the number of team nodes by 1(GET #delete)&lt;br /&gt;
* Inherit team should redirect (POST #inherit)&lt;br /&gt;
* Bequeath team should redirect (POST #bequeath)&lt;br /&gt;
The methods in the following are ignored in testing since they are never used in current codes.&lt;br /&gt;
* create_teams_view&lt;br /&gt;
* create_teams&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not. &lt;br /&gt;
&lt;br /&gt;
==Future Works==&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
''Please note that this bug was reported fixed in the newest version of master branch of expertiza, but the fix came too late''&lt;br /&gt;
&lt;br /&gt;
There are several error raised from ''leave'' method need to be fixed, as mentioned above. Future teams may need to add tests on it as soon as it fixed, since it is a crucial functionality of the student team. &lt;br /&gt;
&lt;br /&gt;
Also, methods that seems like not being used, such as &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; may need to be double checked and see if they are redundant.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84218</id>
		<title>CSC/ECE 517 Spring 2014/oss E1406 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84218"/>
		<updated>2014-04-01T01:07:22Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1406: Improve tests &amp;amp; investigate regex warnings for team functionality=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/controllers/teams_controller.rb ===&lt;br /&gt;
 &lt;br /&gt;
teams_controller contains functionalities for team management for instructor/TA accounts. &lt;br /&gt;
Instructor/TA can:&lt;br /&gt;
* view current teams&lt;br /&gt;
* create new teams&lt;br /&gt;
* import/export teams&lt;br /&gt;
* delete all teams/delete specified team&lt;br /&gt;
* copy existing teams from a course down to an assignment(inherit)&lt;br /&gt;
* update team's information&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/student_team_controller.rb ===&lt;br /&gt;
The student_team_controller support team management for student account.&lt;br /&gt;
student can&lt;br /&gt;
* create team&lt;br /&gt;
* view current team (including team invitations received and sent)&lt;br /&gt;
* advertise for their team&lt;br /&gt;
* remove the advertise for their team&lt;br /&gt;
* leave the team&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
There were no functional tests written on the two controllers to detect bugs, as well as confirming they are functional by itself and after integration.&lt;br /&gt;
&lt;br /&gt;
Our goal is to add comprehensive functional tests and integration tests to the two controllers to provide a preferable test suite for the future developers. &lt;br /&gt;
&lt;br /&gt;
Also, as the classes are influenced by the changes from other, we are also responsible for fixing some of the bugs, refactoring the method names to a better ones, as well as reporting the bugs found in the testing process.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
Overall: contribute to the code coverage, ideally having overall coverage increase 2%&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
* def advertise_for_partners  # change to “advertise”&lt;br /&gt;
* def remove # change to “remove_advertisment”&lt;br /&gt;
* def review # remove this method&lt;br /&gt;
&lt;br /&gt;
===teams_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
&lt;br /&gt;
== Deployment ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/functional/student_team_controller.rb&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/teams_controller&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
;Total Number of Tests : 37&lt;br /&gt;
;Previous Coverage : 22.32%&lt;br /&gt;
;Current Coverage : 24.08% &lt;br /&gt;
&lt;br /&gt;
===Testing Scenarios===&lt;br /&gt;
====student_team_controller====&lt;br /&gt;
Most of the test case are straightforward. There are some of the test cases was commented out due to bug in the controller&lt;br /&gt;
* View student team (GET #view)&lt;br /&gt;
* Edit team (GET #edit)&lt;br /&gt;
* Create team with valid name (POST #create)&lt;br /&gt;
* Create team with name in use (POST #create)&lt;br /&gt;
* Update valid team name (POST #update) &lt;br /&gt;
* Update team name in use (POST #update)&lt;br /&gt;
* Update with current team name (POST #update)&lt;br /&gt;
* Advertise (GET #advertise)&lt;br /&gt;
''This is currently commented out in the committed code. It seems like the method is never called. It raises missing template error upon every call. ''&lt;br /&gt;
The &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; method was previously named advertise_for_partners, but renamed due to ambiguity as there is another class with the same name. &lt;br /&gt;
&lt;br /&gt;
* Remove advertisement (GET #remove_advertisement )&lt;br /&gt;
The &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; method was previously named remove, but renamed to avoid ambiguity&lt;br /&gt;
This method is never called as well, but it is functional as it do not require any template.&lt;br /&gt;
* Leave student team (GET #leave)&lt;br /&gt;
''This is currently commented out in the committed code, because it will raise error every time when called.''&lt;br /&gt;
It seems like problem happens on &lt;br /&gt;
  line 96: other_members = TeamsUser.where( ['team_id = ?', params[:team_id]]).first&lt;br /&gt;
  line 97: if other_members.length == 0&lt;br /&gt;
This will raise error due to the calling length of other_members, which is a single object but not an array.&lt;br /&gt;
Also, the related record seems to be remain undeleted in the database.&lt;br /&gt;
&lt;br /&gt;
====teams_controller====&lt;br /&gt;
Current test cases are as following.&lt;br /&gt;
* Create team should increase the number of teams by 1(GET #create)&lt;br /&gt;
* Create team should increase the number of team nodes by 1(GET #create)&lt;br /&gt;
* Create team with existing name (POST #create)&lt;br /&gt;
* Create team should redirect to list assignments (POST #create)&lt;br /&gt;
* Delete all teams (GET #delete_all)&lt;br /&gt;
* Delete all teams should redirect to list (GET #delete_all)&lt;br /&gt;
* List should receive assignment (GET #list)&lt;br /&gt;
* List should receive course (GET #list)&lt;br /&gt;
* New should assign parent (GET #new)&lt;br /&gt;
* Update team should redirect (POST #update)&lt;br /&gt;
* Update team should have validate name (POST #update)&lt;br /&gt;
* Edit team should have time (POST #edit)&lt;br /&gt;
* Delete team should redirect (POST #delete)&lt;br /&gt;
* Delete team should decrease the number of teams by 1(GET #delete)&lt;br /&gt;
* Delete team should decrease the number of team nodes by 1(GET #delete)&lt;br /&gt;
* Inherit team should redirect (POST #inherit)&lt;br /&gt;
* Bequeath team should redirect (POST #bequeath)&lt;br /&gt;
The methods in the following are ignored in testing since they are never used in current codes.&lt;br /&gt;
* create_teams_view&lt;br /&gt;
* create_teams&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not. &lt;br /&gt;
&lt;br /&gt;
[[File:result.png]]&lt;br /&gt;
&lt;br /&gt;
==Future Works==&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
''Please note that this bug was reported fixed in the newest version of master branch of expertiza, but the fix came too late''&lt;br /&gt;
&lt;br /&gt;
There are several error raised from ''leave'' method need to be fixed, as mentioned above. Future teams may need to add tests on it as soon as it fixed, since it is a crucial functionality of the student team. &lt;br /&gt;
&lt;br /&gt;
Also, methods that seems like not being used, such as &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; may need to be double checked and see if they are redundant.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84216</id>
		<title>CSC/ECE 517 Spring 2014/oss E1406 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84216"/>
		<updated>2014-04-01T00:50:09Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: /* app/controllers/student_team_controller.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1406: Improve tests &amp;amp; investigate regex warnings for team functionality=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/controllers/teams_controller.rb ===&lt;br /&gt;
 &lt;br /&gt;
teams_controller contains functionalities for team management for instructor/TA accounts. &lt;br /&gt;
Instructor/TA can:&lt;br /&gt;
* view current teams&lt;br /&gt;
* create new teams&lt;br /&gt;
* import/export teams&lt;br /&gt;
* delete all teams/delete specified team&lt;br /&gt;
* copy existing teams from a course down to an assignment(inherit)&lt;br /&gt;
* update team's information&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/student_team_controller.rb ===&lt;br /&gt;
The student_team_controller support team management for student account.&lt;br /&gt;
student can&lt;br /&gt;
* create team&lt;br /&gt;
* view current team (including team invitations received and sent)&lt;br /&gt;
* advertise for their team&lt;br /&gt;
* remove the advertise for their team&lt;br /&gt;
* leave the team&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
There were no functional tests written on the two controllers to detect bugs, as well as confirming they are functional by itself and after integration.&lt;br /&gt;
&lt;br /&gt;
Our goal is to add comprehensive functional tests and integration tests to the two controllers to provide a preferable test suite for the future developers. &lt;br /&gt;
&lt;br /&gt;
Also, as the classes are influenced by the changes from other, we are also responsible for fixing some of the bugs, refactoring the method names to a better ones, as well as reporting the bugs found in the testing process.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
Overall: contribute to the code coverage, ideally having overall coverage increase 2%&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
* def advertise_for_partners  # change to “advertise”&lt;br /&gt;
* def remove # change to “remove_advertisment”&lt;br /&gt;
* def review # remove this method&lt;br /&gt;
&lt;br /&gt;
===teams_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
&lt;br /&gt;
== Deployment ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/functional/student_team_controller.rb&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/teams_controller&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
;Total Number of Tests : 37&lt;br /&gt;
;Previous Coverage : 22.32%&lt;br /&gt;
;Current Coverage : 24.08% &lt;br /&gt;
&lt;br /&gt;
===Testing Scenarios===&lt;br /&gt;
====student_team_controller====&lt;br /&gt;
Most of the test case are straightforward. There are some of the test cases was commented out due to bug in the controller&lt;br /&gt;
* View student team (GET #view)&lt;br /&gt;
* Edit team (GET #edit)&lt;br /&gt;
* Create team with valid name (POST #create)&lt;br /&gt;
* Create team with name in use (POST #create)&lt;br /&gt;
* Update valid team name (POST #update) &lt;br /&gt;
* Update team name in use (POST #update)&lt;br /&gt;
* Update with current team name (POST #update)&lt;br /&gt;
* Advertise (GET #advertise)&lt;br /&gt;
''This is currently commented out in the committed code. It seems like the method is never called. It raises missing template error upon every call. ''&lt;br /&gt;
The &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; method was previously named advertise_for_partners, but renamed due to ambiguity as there is another class with the same name. &lt;br /&gt;
&lt;br /&gt;
* Remove advertisement (GET #remove_advertisement )&lt;br /&gt;
The &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; method was previously named remove, but renamed to avoid ambiguity&lt;br /&gt;
This method is never called as well, but it is functional as it do not require any template.&lt;br /&gt;
* Leave student team (GET #leave)&lt;br /&gt;
''This is currently commented out in the committed code, because it will raise error every time when called.''&lt;br /&gt;
It seems like problem happens on &lt;br /&gt;
  line 96: other_members = TeamsUser.where( ['team_id = ?', params[:team_id]]).first&lt;br /&gt;
  line 97: if other_members.length == 0&lt;br /&gt;
This will raise error due to the calling length of other_members, which is a single object but not an array.&lt;br /&gt;
Also, the related record seems to be remain undeleted in the database.&lt;br /&gt;
&lt;br /&gt;
====teams_controller====&lt;br /&gt;
Current test cases are as following.&lt;br /&gt;
* Create team should increase the number of teams by 1(GET #create)&lt;br /&gt;
* Create team should increase the number of team nodes by 1(GET #create)&lt;br /&gt;
* Create team with existing name (POST #create)&lt;br /&gt;
* Create team should redirect to list assignments (POST #create)&lt;br /&gt;
* Delete all teams (GET #delete_all)&lt;br /&gt;
* Delete all teams should redirect to list (GET #delete_all)&lt;br /&gt;
* List should receive assignment (GET #list)&lt;br /&gt;
* List should receive course (GET #list)&lt;br /&gt;
* New should assign parent (GET #new)&lt;br /&gt;
* Update team should redirect (POST #update)&lt;br /&gt;
* Update team should have validate name (POST #update)&lt;br /&gt;
* Edit team should have time (POST #edit)&lt;br /&gt;
* Delete team should redirect (POST #delete)&lt;br /&gt;
* Delete team should decrease the number of teams by 1(GET #delete)&lt;br /&gt;
* Delete team should decrease the number of team nodes by 1(GET #delete)&lt;br /&gt;
* Inherit team should redirect (POST #inherit)&lt;br /&gt;
* Bequeath team should redirect (POST #bequeath)&lt;br /&gt;
The methods in the following are ignored in testing since they are never used in current codes.&lt;br /&gt;
* create_teams_view&lt;br /&gt;
* create_teams&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not. &lt;br /&gt;
&lt;br /&gt;
==Future Works==&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
''Please note that this bug was reported fixed in the newest version of master branch of expertiza, but the fix came too late''&lt;br /&gt;
&lt;br /&gt;
There are several error raised from ''leave'' method need to be fixed, as mentioned above. Future teams may need to add tests on it as soon as it fixed, since it is a crucial functionality of the student team. &lt;br /&gt;
&lt;br /&gt;
Also, methods that seems like not being used, such as &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; may need to be double checked and see if they are redundant.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84215</id>
		<title>CSC/ECE 517 Spring 2014/oss E1406 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2014/oss_E1406_st&amp;diff=84215"/>
		<updated>2014-04-01T00:42:29Z</updated>

		<summary type="html">&lt;p&gt;Xguo6: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E1406: Improve tests &amp;amp; investigate regex warnings for team functionality=&lt;br /&gt;
''Please be advised that we do not have deployment link, since our work are all back-end tests''&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Classes==&lt;br /&gt;
=== app/controllers/teams_controller.rb ===&lt;br /&gt;
 &lt;br /&gt;
teams_controller contains functionalities for team management for instructor/TA accounts. &lt;br /&gt;
Instructor/TA can:&lt;br /&gt;
* view current teams&lt;br /&gt;
* create new teams&lt;br /&gt;
* import/export teams&lt;br /&gt;
* delete all teams/delete specified team&lt;br /&gt;
* copy existing teams from a course down to an assignment(inherit)&lt;br /&gt;
* update team's information&lt;br /&gt;
&lt;br /&gt;
=== app/controllers/student_team_controller.rb ===&lt;br /&gt;
The student_team_controller support team management for student account.&lt;br /&gt;
student can&lt;br /&gt;
* create team&lt;br /&gt;
* view current team (including team invitations received and sent)&lt;br /&gt;
* advertise for their team&lt;br /&gt;
* remove the advertise for their team&lt;br /&gt;
* leave the team&lt;br /&gt;
* &amp;lt;del&amp;gt;review members&amp;lt;/del&amp;gt; (removed)&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
There were no functional tests written on the two controllers to detect bugs, as well as confirming they are functional by itself and after integration.&lt;br /&gt;
&lt;br /&gt;
Our goal is to add comprehensive functional tests and integration tests to the two controllers to provide a preferable test suite for the future developers. &lt;br /&gt;
&lt;br /&gt;
Also, as the classes are influenced by the changes from other, we are also responsible for fixing some of the bugs, refactoring the method names to a better ones, as well as reporting the bugs found in the testing process.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
Overall: contribute to the code coverage, ideally having overall coverage increase 2%&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
* def advertise_for_partners  # change to “advertise”&lt;br /&gt;
* def remove # change to “remove_advertisment”&lt;br /&gt;
* def review # remove this method&lt;br /&gt;
&lt;br /&gt;
===teams_controller===&lt;br /&gt;
* write tests&lt;br /&gt;
&lt;br /&gt;
== Deployment ==&lt;br /&gt;
Please note that all of our work will be under the /test folder, which means they will not show any change on the view. &lt;br /&gt;
To see the result of tests, run &lt;br /&gt;
 rake test TEST=test/functional/student_team_controller.rb&lt;br /&gt;
and &lt;br /&gt;
 rake test TEST=test/functional/teams_controller&lt;br /&gt;
&lt;br /&gt;
running the whole test suite with &amp;lt;code&amp;gt;rake test&amp;lt;/code&amp;gt; is not recommended, as the schema change overtime has broke some of the previous tests.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
;Framework : [http://guides.rubyonrails.org/testing.html Rails default test framework]&lt;br /&gt;
;Sample data : Fixtures (under /test/fixtures)&lt;br /&gt;
;Coverage tool: [https://rubygems.org/gems/simplecov SimpleCov]&lt;br /&gt;
;Total Number of Tests : 37&lt;br /&gt;
;Previous Coverage : 22.32%&lt;br /&gt;
;Current Coverage : 24.08% &lt;br /&gt;
&lt;br /&gt;
===Testing Scenarios===&lt;br /&gt;
====student_team_controller====&lt;br /&gt;
Most of the test case are straightforward. There are some of the test cases was commented out due to bug in the controller&lt;br /&gt;
* View student team (GET #view)&lt;br /&gt;
* Edit team (GET #edit)&lt;br /&gt;
* Create team with valid name (POST #create)&lt;br /&gt;
* Create team with name in use (POST #create)&lt;br /&gt;
* Update valid team name (POST #update) &lt;br /&gt;
* Update team name in use (POST #update)&lt;br /&gt;
* Update with current team name (POST #update)&lt;br /&gt;
* Advertise (GET #advertise)&lt;br /&gt;
''This is currently commented out in the committed code. It seems like the method is never called. It raises missing template error upon every call. ''&lt;br /&gt;
The &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; method was previously named advertise_for_partners, but renamed due to ambiguity as there is another class with the same name. &lt;br /&gt;
&lt;br /&gt;
* Remove advertisement (GET #remove_advertisement )&lt;br /&gt;
The &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; method was previously named remove, but renamed to avoid ambiguity&lt;br /&gt;
This method is never called as well, but it is functional as it do not require any template.&lt;br /&gt;
* Leave student team (GET #leave)&lt;br /&gt;
''This is currently commented out in the committed code, because it will raise error every time when called.''&lt;br /&gt;
It seems like problem happens on &lt;br /&gt;
  line 96: other_members = TeamsUser.where( ['team_id = ?', params[:team_id]]).first&lt;br /&gt;
  line 97: if other_members.length == 0&lt;br /&gt;
This will raise error due to the calling length of other_members, which is a single object but not an array.&lt;br /&gt;
Also, the related record seems to be remain undeleted in the database.&lt;br /&gt;
&lt;br /&gt;
====teams_controller====&lt;br /&gt;
Current test cases are as following.&lt;br /&gt;
* Create team should increase the number of teams by 1(GET #create)&lt;br /&gt;
* Create team should increase the number of team nodes by 1(GET #create)&lt;br /&gt;
* Create team with existing name (POST #create)&lt;br /&gt;
* Create team should redirect to list assignments (POST #create)&lt;br /&gt;
* Delete all teams (GET #delete_all)&lt;br /&gt;
* Delete all teams should redirect to list (GET #delete_all)&lt;br /&gt;
* List should receive assignment (GET #list)&lt;br /&gt;
* List should receive course (GET #list)&lt;br /&gt;
* New should assign parent (GET #new)&lt;br /&gt;
* Update team should redirect (POST #update)&lt;br /&gt;
* Update team should have validate name (POST #update)&lt;br /&gt;
* Edit team should have time (POST #edit)&lt;br /&gt;
* Delete team should redirect (POST #delete)&lt;br /&gt;
* Delete team should decrease the number of teams by 1(GET #delete)&lt;br /&gt;
* Delete team should decrease the number of team nodes by 1(GET #delete)&lt;br /&gt;
* Inherit team should redirect (POST #inherit)&lt;br /&gt;
* Bequeath team should redirect (POST #bequeath)&lt;br /&gt;
The methods in the following are ignored in testing since they are never used in current codes.&lt;br /&gt;
* create_teams_view&lt;br /&gt;
* create_teams&lt;br /&gt;
&lt;br /&gt;
==Sample Test Code==&lt;br /&gt;
We show two pieces of test code for two controllers to explain how our test works&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_student team with name in use&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:student8))&lt;br /&gt;
        post(:create, {'team' =&amp;gt; { 'name' =&amp;gt; 'IntelligentTeam2'}, 'id' =&amp;gt; participants(:par21).id, &amp;quot;commit&amp;quot; =&amp;gt; &amp;quot;Create Team&amp;quot;}, sessionVars, nil)&lt;br /&gt;
        assert_equal 'Team name is already in use.', flash[:notice]&lt;br /&gt;
        assert_redirected_to :controller =&amp;gt; 'student_team', :action =&amp;gt; 'view', :id =&amp;gt; participants(:par21).id&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    test &amp;quot;create_should_increase_number_of_teams_course&amp;quot; do&lt;br /&gt;
        sessionVars = session_for(users(:instructor1))&lt;br /&gt;
        sessionVars[:team_type] = &amp;quot;Course&amp;quot;&lt;br /&gt;
        assert_difference 'Team.count' do&lt;br /&gt;
          get :create, {'id' =&amp;gt; @testCourse,'team' =&amp;gt; {'name' =&amp;gt; &amp;quot;Random&amp;quot;}},sessionVars&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The first piece of code is from student_team_controller.rb. It tests if there is already a same team name when student8 want to create a team. The second piece of code is from teams_controller_test.rb. It tests if the team number decreases when instructor1 creates a new team for a course.&lt;br /&gt;
&lt;br /&gt;
As we can see from the code, when we want to use &amp;lt;code&amp;gt;post&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt;, several parameters are needed. Usually we use four parameters: First, the method we are requesting. Second, an hash of request parameters for the method. Third, an optional hash of session variables. Forth, an optional hash of flash values. If we do not want to pass in the optional hash, we can set it to nil as the first piece of code shows, or we can just leave it blank as the second piece of code shows.&lt;br /&gt;
&lt;br /&gt;
When we run the command &amp;lt;code&amp;gt;rake test TEST=test/functional/your_test_file.rb&amp;lt;/code&amp;gt;, you will see if the test is passed or not. &lt;br /&gt;
&lt;br /&gt;
==Future Works==&lt;br /&gt;
===student_team_controller===&lt;br /&gt;
''Please note that this bug was reported fixed in the newest version of master branch of expertiza, but the fix came too late''&lt;br /&gt;
&lt;br /&gt;
There are several error raised from ''leave'' method need to be fixed, as mentioned above. Future teams may need to add tests on it as soon as it fixed, since it is a crucial functionality of the student team. &lt;br /&gt;
&lt;br /&gt;
Also, methods that seems like not being used, such as &amp;lt;code&amp;gt;advertise&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;remove_advertisement&amp;lt;/code&amp;gt; may need to be double checked and see if they are redundant.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xguo6</name></author>
	</entry>
</feed>