A Console application to zip the folders present in a particular folder and again zip the zipped folder.
This small application is very useful in scenarios when one want to archive project files periodically. And where zipping of files take lots of time if done manually.
Create a console application. And name it as zip_utility. Specify the path you want to save it in. By default it will be in MyDocuments\VisualStudioProjects.
Include the following namespaces to the class…
using System.Text;
using System.IO;
using System.Collections;
using System.Diagnostics;
using System.Configuration;
using System.Threading;
using System.Windows.Forms;
Next step will be to write down the method which zips the folders. Lets call it as “Zipme()”.It first deletes all the .zip files that are already present in the particular folder,so that there is no confusion between already existing and new files,and again zip the folders afresh.then you can copy the resulting folder where the backup is kept.This tool is basically used to take the backups of the project folders at regular intervals. It becomes quiet cumbersome to zip each folder one at a time. It takes time and also monitoring for quiet sometime. By this tool we are intending to reduce the mentioned efforts.
It will be using winzip 9.0 with commandline support.
We will also be using a config file called “App.config” which will serve the purpose of setting some values.
Now add following class
private static void Zipme()
{
// “ZipFolder” is used as the key in the App.config
// FolderN is being set to the value assigned to the ZipFolder in App.config
string FolderN= ConfigurationSettings.AppSettings["ZipFolder"].ToString();
try
{
EmptyFolder(FolderN); //call to delete existing .zip files
//region defined to compress the subfolders.
#region for subdirectories
string[] dirs = Directory.GetDirectories(FolderN); //get info of subdirectories in FolderN
foreach(string dir in dirs)
{
Process cmd1 = new Process();
string path = Path.GetFullPath(dir);
cmd1.StartInfo.FileName = "cmd.exe";
cmd1.StartInfo.RedirectStandardInput = true;
cmd1.StartInfo.RedirectStandardOutput = true;
cmd1.StartInfo.CreateNoWindow = false;
cmd1.StartInfo.UseShellExecute = false;
cmd1.Start();
// command with parameters to compress
string strPath = @"C: && cd C:\Program Files\WinZip && WZZIP -whs -rP"+" "+ "\"" + dir+".zip"+ "\"" + " "+ "\"" + path+"\\*.*" + "\"" ;
cmd1.StandardInput.WriteLine(strPath);
Thread.Sleep(500);
// since using commandline support, it needs user to press a key as soon as one folder is zipped to continue for next,hence sending "ENTER"
SendKeys.SendWait("{ENTER}");
cmd1.StandardInput.Flush();
cmd1.StandardInput.Close();
Console.WriteLine(cmd1.StandardOutput.ReadToEnd());
}
#endregion for subdirectories
#region Directory Compression
Process cmd = new Process();
cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.RedirectStandardOutput =true;
cmd.StartInfo.CreateNoWindow = false;
cmd.StartInfo.UseShellExecute = false;
cmd.Start();
string zipCmd = @"C: && cd C:\Program Files\WinZip && WZZIP";
string strSep = " ";
// naming the folder with the date of creation appended to the folder name
string strPathDest = ConfigurationSettings.AppSettings["FinalZipFolder"].ToString() + "\\" + ConfigurationSettings.AppSettings["FinalZipName"].ToString() + DateTime.Now.ToShortDateString().Replace(@"/", "-") + @".ZIP";
string strPathSource = ConfigurationSettings.AppSettings["FinalZipFolder"].ToString() + @"\*.ZIP";
string strPath1 = zipCmd + strSep +"\""+ strPathDest+"\"" + strSep +"\""+ strPathSource+"\"";
cmd.StandardInput.WriteLine(strPath1);
Thread.Sleep(500);
SendKeys.SendWait("{ENTER}");
cmd.StandardInput.Flush();
cmd.StandardInput.Close();
Console.WriteLine(cmd.StandardOutput.ReadToEnd());
#endregion Directory Compression
}
catch(Exception e)
{
Console.WriteLine(e.Message);
string wait = Console.ReadLine();
}
}
add a web configuration file solution explorer -> add -> new item -> web configuration file and name it App.config file and put following code in appsettings tag
put each line in angle brackets with "/" before bracket close for each line. since having problem in publishing this code..
add key="ZipFolder" value="D:\zip_folder"
add key="FinalZipFolder" value="D:\zip_folder"
add key="FinalZipName" value="zip"
February 9, 2009
Console Application to zip your files
June 10, 2008
Extreme Testing
The 12 Practices of Extreme Programming
(ref :The Art of Software Testing by Glenford J. Myers Revised and Updated by Tom Badgett and Todd M.Thomas with Corey Sandler)
1. Planning and requirements
1. Planning and requirements
• Marketing and business development personnel gathering work together to identify the maximum
business value of each software feature.
• Each major software feature is rewritten as a user story.
• Programmers provide time estimates to complete each user story.
• The customer chooses the software features based on time estimates and business value.
2. Small, incremental releases
• Each major software feature is rewritten as a user story.
• Programmers provide time estimates to complete each user story.
• The customer chooses the software features based on time estimates and business value.
2. Small, incremental releases
• Strive to add small, tangible, value added features and release a new code base often.
3. System metaphors
3. System metaphors
• Your programming team identifies an organizing metaphor to help with naming conventions and program flow.
4. Simple designs
4. Simple designs
• Implement the simplest design that allows your code to pass its unit tests. Assume change will come,so
don’t spend a lot of time designing; just implement.
5. Continuous testing
5. Continuous testing
• Write unit tests before writing their code module. Each unit is not complete until it passes its unit test.In
addition, the program is not complete until it passes all unit tests and acceptance tests are complete.
6. Refactoring
6. Refactoring
• Clean up and streamline your code base. Unit tests help ensure that you do not destroy the functionality in
the process. You must rerun all unit tests after any refactoring.
7. Pair programming
• You and another programmer work together, at the same machine, to create your code base. This allows for
real-time code review, which dramatically increases bug detection and resolution.
8. Collective ownership of the code
real-time code review, which dramatically increases bug detection and resolution.
8. Collective ownership of the code
• All code is owned by all programmers.No single base programmer is dedicated to a specific code base.
9. Continuous integration
9. Continuous integration
• Every day, integrate all changes, after it passes the unit tests, back into the code base.
10. 40-hour work week
10. 40-hour work week
• No overtime is allowed. If you work with dedication for 40 hours per week, then overtime will not be
needed.The exception is the week before a major release.
11. On-site customer
11. On-site customer
• You and your programming team have unlimited access to the customer so you may resolve questions quickly and decisively, which keeps the development process from stalling.
12. Coding standards
12. Coding standards
• All code should look the same.Developing a system metaphor helps meet this principle.
Extreme Testing: The Concepts
To meet the pace and philosophy of XP, developers use extreme testing,which focuses on constant testing. Two forms of testing make up the bulk of XT: unit testing and acceptance testing. The theory used when writing the tests does not vary significantly from the theory of Module(unit) testing. However,the stage in the development process in which you create the tests does differ. Nonetheless, XT and traditional testing still have the same goal: to identify errors in a program
Extreme Unit Testing
Unit testing is the primary testing approach used in Extreme Testing and has two simple rules: All code modules must have unit tests before coding begins, and all code modules must pass unit tests before being released into production. At first glance this may not seem so extreme. However, the big difference between unit testing,and XT is that the unit tests must be defined and created before coding the module.Initially, you may wonder why you should, or how you can, create test drivers for code you haven’t even written. You may also think that you do not have time to create the tests because the application must meet a deadline. These are valid concerns, but they are easily addressed. The following list identifies some benefits associated with writing unit tests before you start coding the application.
• You gain confidence that your code will meet its specification.
• You express the end result of your code before you start coding.
• You better understand the application’s specification and requirements.
• You may initially implement simple designs and confidently refactor the code later to improve performance without worrying about breaking the specification.
Of these benefits, the insight and understanding you gain of the application’s specification and requirements cannot be underestimated.
For example, you may not fully understand the acceptable data types and boundaries for the input values of an application if you start coding first. So how can you write a unit test to perform boundary analysis without understanding the acceptable inputs? Can the application accept only numbers, only characters, or both? If you create the unit tests first, you must understand the specification. The practice of creating unit tests first is the shining point of the XP methodology, as it forces you to understand the specification to resolve ambiguities before you begin coding.
Only you, as the programmer, know the architecture of the application and how best to build the unit tests for it.
Manually running unit tests, even for the smallest application, can be a daunting task. As the application grows, you may generate hundreds or thousands of unit tests. Therefore, you typically use an automated software testing suite to ease the burden of constantly running unit tests. With these suites you script the tests and then run all or part of them. In addition, testing suites typically allow you to create reports and classify the bugs that frequently occur in your application. This information may help you proactively eliminate bugs in the future.Interestingly enough, once you create and validate your unit tests,the “testing” code base becomes as valuable as the software application you are trying to create. As a result, you should keep the tests in a code repository for protection. In addition, you should ensure that adequate backups occur, as well as that the needed security is in place.
Acceptance Testing
Acceptance testing represents the second, and an equally important,type of XT that occurs in the XP methodology. The purpose of acceptance testing is to determine whether the application meets other requirements such as functionality and usability. You and the customer create the acceptance tests during the design/planning phases.Unlike the other forms of testing customers, not you or your programming partners, conduct the acceptance tests. In this manner, customers provide the unbiased verification that the application meets their needs. Customers create the acceptance tests from user stories. The ratio of user stories to acceptance tests is usually one to many. That is, more than one acceptance test may be needed for each user story. Acceptance tests in XT may or may not be automated. For example, an unautomated test is required when the customer must validate that a user-input screen meets its specification with respect to color
and screen layout. An example of an automated test is when the application must calculate payroll values using data input via some data source such as a flat file to simulate production values.
With acceptance tests, the customer validates an expected result from the application. A deviation from the expected result is considered a bug and is reported to the development team. If customers discover several bugs, then they must prioritize them before passing the list to your development group. After you correct the bugs, or after any change, the customers rerun the acceptance tests. In this manner,the acceptance tests also become a form of regression testing.
An important note is that a program can pass all unit tests but fail the acceptance tests. Why? Because a unit test validates whether a program unit meets some specification such as calculating payroll deductions correctly, not some defined functionality or aesthetics.For a commercial application, the look and feel is a very important component. Understanding the specification, but not the functionality,generally creates this scenario.
Unit testing is the primary testing approach used in Extreme Testing and has two simple rules: All code modules must have unit tests before coding begins, and all code modules must pass unit tests before being released into production. At first glance this may not seem so extreme. However, the big difference between unit testing,and XT is that the unit tests must be defined and created before coding the module.Initially, you may wonder why you should, or how you can, create test drivers for code you haven’t even written. You may also think that you do not have time to create the tests because the application must meet a deadline. These are valid concerns, but they are easily addressed. The following list identifies some benefits associated with writing unit tests before you start coding the application.
• You gain confidence that your code will meet its specification.
• You express the end result of your code before you start coding.
• You better understand the application’s specification and requirements.
• You may initially implement simple designs and confidently refactor the code later to improve performance without worrying about breaking the specification.
Of these benefits, the insight and understanding you gain of the application’s specification and requirements cannot be underestimated.
For example, you may not fully understand the acceptable data types and boundaries for the input values of an application if you start coding first. So how can you write a unit test to perform boundary analysis without understanding the acceptable inputs? Can the application accept only numbers, only characters, or both? If you create the unit tests first, you must understand the specification. The practice of creating unit tests first is the shining point of the XP methodology, as it forces you to understand the specification to resolve ambiguities before you begin coding.
Only you, as the programmer, know the architecture of the application and how best to build the unit tests for it.
Manually running unit tests, even for the smallest application, can be a daunting task. As the application grows, you may generate hundreds or thousands of unit tests. Therefore, you typically use an automated software testing suite to ease the burden of constantly running unit tests. With these suites you script the tests and then run all or part of them. In addition, testing suites typically allow you to create reports and classify the bugs that frequently occur in your application. This information may help you proactively eliminate bugs in the future.Interestingly enough, once you create and validate your unit tests,the “testing” code base becomes as valuable as the software application you are trying to create. As a result, you should keep the tests in a code repository for protection. In addition, you should ensure that adequate backups occur, as well as that the needed security is in place.
Acceptance Testing
Acceptance testing represents the second, and an equally important,type of XT that occurs in the XP methodology. The purpose of acceptance testing is to determine whether the application meets other requirements such as functionality and usability. You and the customer create the acceptance tests during the design/planning phases.Unlike the other forms of testing customers, not you or your programming partners, conduct the acceptance tests. In this manner, customers provide the unbiased verification that the application meets their needs. Customers create the acceptance tests from user stories. The ratio of user stories to acceptance tests is usually one to many. That is, more than one acceptance test may be needed for each user story. Acceptance tests in XT may or may not be automated. For example, an unautomated test is required when the customer must validate that a user-input screen meets its specification with respect to color
and screen layout. An example of an automated test is when the application must calculate payroll values using data input via some data source such as a flat file to simulate production values.
With acceptance tests, the customer validates an expected result from the application. A deviation from the expected result is considered a bug and is reported to the development team. If customers discover several bugs, then they must prioritize them before passing the list to your development group. After you correct the bugs, or after any change, the customers rerun the acceptance tests. In this manner,the acceptance tests also become a form of regression testing.
An important note is that a program can pass all unit tests but fail the acceptance tests. Why? Because a unit test validates whether a program unit meets some specification such as calculating payroll deductions correctly, not some defined functionality or aesthetics.For a commercial application, the look and feel is a very important component. Understanding the specification, but not the functionality,generally creates this scenario.
---The Art of Software Testing by
Glenford J. Myers
Revised and Updated by
Tom Badgett and Todd M.Thomas
with Corey Sandler
Glenford J. Myers
Revised and Updated by
Tom Badgett and Todd M.Thomas
with Corey Sandler
April 25, 2008
Types of Test Reports
Types of Test Reports
The documents outlined in the IEEE Standard of Software Test Documentation covers test planning, test specification, and test reporting.Test reporting covers four document types:
1. A Test Item Transmittal Report identifies the test items being transmitted for testing from the development to the testing group in the event that a formal beginning of test execution is desired Details to be included in the report - Purpose, Outline, Transmittal-Report Identifier, Transmitted Items, Location, Status, and Approvals.
2. A Test Log is used by the test team to record what occurred during test execution.
Details to be included in the report - Purpose, Outline, Test-Log Identifier, Description, Activity and Event Entries, Execution Description, Procedure Results, Environmental Information, Anomalous Events, Incident-Report Identifiers
3. A Test Incident report describes any event that occurs during the test execution that requires further investigation Details to be included in the report - Purpose, Outline, Test-Incident-Report Identifier, Summary,
Impact
4. A test summary report summarizes the testing activities associated with one or more testdesign specifications Details to be included in the report - Purpose, Outline, Test-Summary-Report Identifier,Summary, Variances, Comprehensiveness Assessment, Summary of Results, Summary of Activities, and Approvals
The documents outlined in the IEEE Standard of Software Test Documentation covers test planning, test specification, and test reporting.Test reporting covers four document types:
1. A Test Item Transmittal Report identifies the test items being transmitted for testing from the development to the testing group in the event that a formal beginning of test execution is desired Details to be included in the report - Purpose, Outline, Transmittal-Report Identifier, Transmitted Items, Location, Status, and Approvals.
2. A Test Log is used by the test team to record what occurred during test execution.
Details to be included in the report - Purpose, Outline, Test-Log Identifier, Description, Activity and Event Entries, Execution Description, Procedure Results, Environmental Information, Anomalous Events, Incident-Report Identifiers
3. A Test Incident report describes any event that occurs during the test execution that requires further investigation Details to be included in the report - Purpose, Outline, Test-Incident-Report Identifier, Summary,
Impact
4. A test summary report summarizes the testing activities associated with one or more testdesign specifications Details to be included in the report - Purpose, Outline, Test-Summary-Report Identifier,Summary, Variances, Comprehensiveness Assessment, Summary of Results, Summary of Activities, and Approvals
Subscribe to:
Posts (Atom)