Category Archives: CS-443

Test Driven Development

When you go to write code, maybe you already know what you want the code to do, knowing what it should give you as outputs and answers, but you might not know how to go about writing the code itself. In test driven development, you start with writing the tests first, and then trying to pass those tests, slowly as you go. It sounds like a strange approach to it but it is not as bad as it sounds.

In this blog post, Arek Torczuk talks about test driven development, and how it is the best thing that can happen to software development. First, they start off by describing test driven development, where they say it is, simply, a failing phase, a passing phase, and then a refactoring phase. In the failing phase, we create a test that will fail. In the passing phase, we create or write code, minimal code, that will pass the test. In the refactoring phase, we clean up the tests. Typically with coding, you would write the code, and then write tests. However, Torczuk presents some problems with this way of code development, like when to stop writing tests, or when you are sure implementation is finished. With test driven development, they say there are benefits, such as when writing tests, it makes you ask yourself, what do you want the code to do. They say that you should know the answers to these tests before the code is written. They then go on to provide situations where code may be impossible to test, and how test driven development can be used to help that, like using mocking. They provide code examples with these too, to further help visualize solutions. They provide some additional sources at the end of the article in the event you would like to learn more about test driven development. 

This is a strange way to write code, and for those used to writing code before everything else, this can be a difficult adjustment. Personally, I found it fairly difficult to start, but afterwards I was able to write the tests, and then write the code to pass those tests, and then keep doing that. The tests do provide a build up of the code, instead of doing everything all at once, which was what Torczuk was trying to get at with his blog post. It allows the tests to provide the framework of the code and lay it out. 

From the blog CS@Worcester – Cao's Thoughts by antcao and used with permission of the author. All other rights reserved by the author.

Testing With Stubs

Recently in my Cs-443 class, Software Quality Assurance and Testing, we have been talking about unit testing using stubs. Honestly, I didn’t understand what stubs were during the classes themselves, but a blog called Why Stubs in Unit Testing Improve Integration Testing helped me understand what a stub is, as well as where and when it is used. In this blog written by Miroslaw Zielinski, he states ” Unit testing is more about isolating the function, method, or procedure, otherwise referred to as a unit. This isolation is done by stubbing out dependencies and forcing specific paths of execution. Stubs take the place of the code in the unit that is dependent on code outside the unit.” Stubs allow the person testing the code to test specific paths of execution within the code, allowing them to view different things such as if different parts of the code work and are reliable. I think that Zielinski gives a great example of why these stubs are used in his article. He states, “Once the stub is added, it will be consistently applied to the tested code. A user working on the “allocation failure” test case will have an easy way to install a special callback function into the stub, which will simulate the desired effect: allocation failure or do nothing since by default the stub returns a null pointer, which is expected for the test case.” This helped me understand why stubs are used, and the rest of the article helped me understand when they are used.

After reading more of the article, Zielinski began to explain why stubs are used. Although his explanation confused me a bit, I believe I got the jist of what he was trying to say. I believe that they are being used when you are trying to test lower-level modules while the upper-level modules have not been developed yet. Therefore you can use a stub, which acts like an upper-level module, in order to see how it will be treated. Zielinski also gives examples of when stubs aren’t good to use and what the limitations are “In instances where there’s not an original definition available for a stubbed function, what happens? How does the stub behave without a callback that defines the alternative behavior? The beauty of C/C++test is that it automatically detects this kind of situation. The stub will reconfigure itself during the test harness build time. It won’t call the original definition when no callback is installed and will return a safe default value.” I’m not really sure what he means by this, but I hope to learn more in the future.

Link: https://www.parasoft.com/blog/using-stubs-in-integration-level-testing/#:~:text=Unit%20testing%20is%20more%20about,on%20code%20outside%20the%20unit.

From the blog CS@Worcester – One pixel at a time by gizmo10203 and used with permission of the author. All other rights reserved by the author.

System Testing

System testing is a process of verifying the end behavior of a software application. System testing finds any errors, spaces, and missing requirements that could affect the software’s functionality. This is usually done after all the tests are completed, it’s important to test the software before releasing it to users. System testing main goals are to reduce risks, prevent defects, verify the design, and validate the system. System testing is an important step in ensuring the software is of great quality before it goes live. Addressing and identifying the errors or issues before making the software live can reduce any risks and make sure that it works perfectly for the users. Verifying the functionality of the completed system will help determine if it meets the requirements specified for that system. This is the best way to prevent any defects, errors, and missing requirements. System testing is also used to check if the system has been designed correctly and follows all the specifications. The process of verifying the accuracy and completeness of the system is the main objective of system testing. It’s to provide confidence that the system meets all of its requirements and will run as expected.

There are different types of system testing to look out for and plan for such as setting up the environment for the test case, creating a test case, creating test data, and running the test case. It’s important to make sure that the environment is set up so that you can write test cases by making sure that it has the right tools and frameworks that will be needed. When creating the test cases it’s important to make sure that the test case has all the necessary details about what the test case is testing for as well as how it will test it. The test data is created in thought of the inputs and outputs for the test case. While creating the test data it’s important to cover all of the critical fields and that nothing is left out. When running the test cases you want to make sure that it puts out the correct output, it should show if it passed or failed. I chose this topic because system testing is important to make sure that our system meets the requirements and runs without any problems. We started working on test cases recently so I thought getting more information on system testing would benefit our skills and any questions that anyone might have.

https://blog.qasource.com/what-is-system-testing-an-ultimate-beginners-guide

From the blog CS@Worcester – Kaylene Noel's Blog by Kaylene Noel and used with permission of the author. All other rights reserved by the author.

A Look at Test-Driven Development & Benefits

Since just before Spring Break, in CS443 – Software Quality Assurance and Testing we have transitioned on from boundary/equivalence class analysis and onto Test-Driven Development as a strategy as well as implementation. For me, this is a huge relief and joy to get back to working on actual code rather than theoretical comp. sci. work, though it also helped me recognize the importance of non-coding exercises. 

I’ve also been really enjoying TDD as I find it aligns with my general coding habits and builds off them to help me identify new coding practices and strategies for addressing challenges. So I decided to look at some blog posts discussing it and how it’s impacted software projects versus other methods used. Test Driven Development Is the Best Thing to Happen to Software Design instantly jumped out to me.

The post discusses the significant influence of Test Driven Development (TDD) on software design. It explains TDD as an iterative approach shaping an idea into implementation through a cyclical process of ‘fail-pass-refactor’. The author illustrates the two approaches to writing code and tests: one driven by code and the other driven by tests, emphasizing the benefits of TDD in terms of mindset and code quality.

This post also considers TDD in real-world scenarios, highlighting its capacity to provide fast strategic approaches to software challenges that may seem to have no place to start (by creating tests). It addresses challenges in testing and offers solutions such as spying or mocking, managing variable test data, avoiding bloated setup, and preventing “Mocking Hell.”

Additionally, the post discusses the tendency to add unnecessary features in code and how TDD, by its nature, prevents such occurrences, thus aligning with the principle of “You Ain’t Gonna Need it” (YAGNI). This is definitely a fault that I fall victim to at times as I try to plan ahead too far in a project and add unnecessary code so I appreciate strategies to address it. Finally, it suggests that TDD not only aids in requirements meeting implementation but also serves as a technique for gathering feedback about software design, thereby advocating for Test Driven Design (TDD).

My typical strategy for developing code begins with creating a skeleton of basic components I expect to be easy to implement and then fill out the boundaries and remainders by developing minor unit tests (like print lines) to make sure it is working as intended. I sometimes do them at the same time, but I have been doing TDD sometimes without knowing it and am now better prepared to hone in on its benefits.

Source:

https://www.thoughtworks.com/en-us/insights/blog/test-driven-development-best-thing-has-happened-software-design

From the blog CS@Worcester – Tech. Worth Talking About by jelbirt and used with permission of the author. All other rights reserved by the author.

TDD

It’s certainly been a while since my last post. I’ve been slacking way too hard, especially with break, but now it’s time to lock in and focus on my work. 

For this blog post, I’ll be talking about Test Driven Development, or TDD for short. TDD is a “software development practice that focuses on creating unit test cases before developing the actual code.” It attempts to avoid or solve the issues that arise in “traditional testing.” TDD, rather than testing one big system, tests small chunks of code at a time. It also “follows an iterative process, where small chunks of code are developed, tested, and refined until they pass all tests.” This allows for errors to be found, debugged, and fixed as early as possible in the development process (BrowserStack).

In Kent Beck’s blogpost, “Canon TDD,” he lists the steps to properly adhering to TDD:

  1. Write a list of the test scenarios you want to cover
  2. Turn exactly one item on the list into an actual, concrete, runnable test
  3. Change the code to make the test (& all previous tests) pass (adding items to the list as you discover them)
  4. Optionally refactor to improve the implementation design
  5. Until the list is empty, go back to #2

Being introduced to a process that differs so much from the “norm” and is also quite efficient and thorough is both refreshing and exciting to learn about. When this topic was first introduced in class, I was very lost but I picked it up not long after; but then again, the example we followed was a very simple one. Once we moved onto a more advanced one to work on within our groups, I was lost again. I understand the concept of Test Driven Development but putting it into practice, at least for now, seems pretty hard. It also seems like a skill that is easy to pick up but hard to master as some tests can be more beneficial than others when it comes to coverage or time management. 

I feel as though there are little downsides to TDD and when it comes to those downsides, they mostly lie in the capability of the individual. Forgetting to run tests, writing too many tests, writing too much for a test, and writing tests that are impractical are just some of the issues that may arise when using this practice. 

Overall, Test Driven Development is a practice that individuals and teams may want to use to try something new or to test if it’s more effective than their current one. It‘s a very different approach to the development processes that I’m familiar with but that’s not always a bad thing; and in this case, TDD seems like a great practice.

Sources Used:

https://www.browserstack.com/guide/what-is-test-driven-development

https://tidyfirst.substack.com/p/canon-tdd

From the blog CS@Worcester – Kyler's Blog by kylerlai and used with permission of the author. All other rights reserved by the author.

Security Testing

For this week’s blog post, I decided to discuss the article “Security Testing: Types, Tools, and Best Practices” by Oliver Moradov. I chose this article because it compliments the security testing topic in the syllabus. This article discusses the main goals of security testing and the key principles behind security testing, and several examples of security testing and testing tools. In this blog post I will be discussing the section on the main goals of security testing

The first section of this article discusses security testing. The article defines security testing as a series of tests determining if the software is vulnerable to cyber-attacks. “Security testing checks whether the software is vulnerable to cyber-attacks and tests the impact of malicious or unexpected inputs on its operations. Security testing provides evidence that systems and information are safe and reliable and that they do not accept unauthorized inputs.” The article also describes security testing as a non-functional form of testing, which means that security testing does not focus on the software’s functionality. Security testing fits more into the category of non-functionality testing, meaning that security testing tests whether or not the application is designed or configured correctly. “Security testing is a type of non-functional testing. Unlike functional testing, which focuses on whether the software’s functions are working properly (“what” the software does), non-functional testing focuses on whether the application is designed and configured correctly (“how” it does it). “

The main goals attributed to security testing mentioned in the article are: identify assets, identify threats and vulnerabilities, identify risk, and perform remediation. The article defines identify assets as: “things that need to be protected, such as software applications and computing infrastructure.” This is essentially what the name describes. It is about finding what needs to be protected. The article then defines identify threats and vulnerabilities as: “activities that can cause damage to an asset, or weaknesses in one or more assets that can be exploited by attackers.” Much like the prior goal mentioned, this one is also fairly self explanatory. It is about finding weaknesses within the software and possible threats that are present. The third main goal the article mentions, identify risk is defined as : “security testing aims to evaluate the risk that specific threats or vulnerabilities will cause a negative impact to the business. Risk is evaluated by identifying the severity of a threat or vulnerability, and the likelihood and impact of exploitation.” Unlike the prior main goals, which are more focused on finding specific instances of something, identify risk is about evaluating the risk being identified not finding it. The last main goal that the article discusses is perform remediation and it is defined as: “security testing is not just a passive evaluation of assets. It provides actionable guidance for remediating vulnerabilities discovered, and can verify that vulnerabilities were successfully fixed.” This main goal is also unique when compared to the prior goals because this goal is focused on finding a solution to a vulnerability.

From the blog CS@Worcester – P. McManus Worcester State CS Blog by patrickmcmanus1 and used with permission of the author. All other rights reserved by the author.

Test Driven Development

The blog “Test Driven Development: The Best Thing That Has Happened to Software Design” explains the benefits of using Test Driven Development  in software development. It describes the focus on writing tests before writing the code, it emphasizes on how this approach will enhance software design, increase code quality, and allow for easier maintainability. The post highlights Test Driven Development’s ability to shift focus towards desired software behavior. I chose this blog post due to its relevance to the recently covered topics in class as well as how it can apply in writing better code. Test Driven Development is a topic that we just covered in class and I found it very interesting to see its uses and benefits.. Additionally, I am using this style of code in my CS-497 class which allowed me to further get hands-on experience with how Test Driven Development works.

After reading the blog post, I agreed with many of the points raised by the author of the blog. I found the idea of writing the tests first as a foundation of code construction seems like a great idea as when you are writing code you know how you want it to work which is how you will write the tests to make it pass. Once you have the tests you can write the code that will allow the tests that you have already created to pass. The idea of problem-solving to make the tests pass rather than troubleshooting seems like an efficient way of coding. The author highlighted an aspect of Test Driven Development that I found very beneficial as it can highly increase efficiency is how creating the tests first gives you better insight on how your code is not working properly. If you are getting the wrong output making your test fail you will know how to fix it better than without having that test in place.

This blog post allowed me to consider different aspects of solutions for coding because different styles have different benefits while developing  software. In addition, it reinforced the importance of writing clean, concise code and underscored the significance of thorough testing which are also key aspects of this class.Moving forward, I would like to and plan to incorporate the style of Test Driven Development more into my coding practices. By focusing first on test creation and then writing the code to make the tests pass, I can aim to enhance the efficiency and quality of my code. In conclusion, I believe that using Test Driven Development will increase my workflow and coding skills that will be beneficial not only in this class but potentially for the rest of my career.

https://www.thoughtworks.com/en-us/insights/blog/test-driven-development-best-thing-has-happened-software-design

From the blog CS@Worcester – Giovanni Casiano – Software Development by Giovanni Casiano and used with permission of the author. All other rights reserved by the author.

Understanding and Prevention


Common Defects in Software Development

In the fast-paced world of software development, the creation of bug-free software remains a significant challenge. Despite advancements in technology and methodology, software defects or bugs continue to impede the smooth functioning of applications. Understanding the reasons behind these defects is crucial for developing more reliable and efficient software systems.

1. Human Error: A Prime Culprit

Human error remains one of the primary sources of software defects. This can range from simple typos in the code to more complex errors in logic or algorithm design. Programmers, regardless of their experience level, are susceptible to making mistakes, especially when working under pressure or tight deadlines. To mitigate this, implementing a robust review process, including peer reviews and pair programming, can help in identifying and rectifying errors early in the development cycle.

2. The Complexity Conundrum

As software systems grow in complexity, the likelihood of defects increases exponentially. Complex systems require a deep understanding and meticulous handling to ensure all parts work seamlessly together. Breaking down the software into smaller, more manageable modules can aid in reducing complexity and making the system more understandable and less prone to errors.

3. The Testing Trap

A common pitfall in software development is insufficient testing. Skipping comprehensive testing phases or having inadequate test coverage can lead to defects slipping into the production environment. Adopting a continuous testing approach and utilizing automated testing tools can help ensure thorough examination and identification of potential issues before deployment.

4. Documentation Dilemmas

Inadequate or outdated documentation can significantly contribute to software defects. Proper documentation ensures that developers have a clear understanding of the software’s design and functionality, facilitating easier debugging and maintenance. Investing time in maintaining detailed and up-to-date documentation can save considerable time and effort in the long run.

5. Tool Troubles

The choice and use of software development tools can also impact the quality of the final product. Using outdated or unsuitable tools can introduce bugs into the system. It is essential to select the right tools that align with the project’s needs and ensure they are correctly integrated and used effectively.

Prevention is Better than Cure

Addressing these common causes of software defects begins with acknowledging their presence and potential impact. By taking proactive steps such as enhancing the development process, enforcing coding standards, conducting regular code reviews, and ensuring comprehensive testing, developers can significantly reduce the occurrence of defects.

Furthermore, fostering a culture that values quality and attention to detail can encourage developers to take the necessary time and care to produce higher-quality code. Investing in training and continuous learning can also equip developers with the skills and knowledge needed to avoid common pitfalls.

The link to the blog I chose : https://www.devstringx.com/why-bugs-or-defects-in-your-software

From the blog CS@Worcester – Coding by asejdi and used with permission of the author. All other rights reserved by the author.

Week 10 Blog Post

Searching for an article this week I looked for something relating to mocking. Considering last week I did the negatives on mocking I think it’s valuable to have various perspectives. Seeing multiple ideas with mocking can give us an idea of how to implement them in the future. The writer of this article is a reliable source being a Java script developer. Getting information from someone in the industry can give a perspective inside the workforce and how people inside see different ideas. Not everyone may agree with using the same coding language but seeing how developers see different concepts can give an idea of the drawbacks to stuff and where in our own experiences can we improve. Overall this article is a great way to see how mocking is seen inside the workforce by an experienced professional.   

In this article, Eric Elliot focuses on the drawbacks of excessive mocking. He points out how brittle tests and how they can be easily broken. There broken simply just from the change of implementation even though the behavior stays the same. Another point is a false sense of security because of there lack of accuracy that occurs from not using accurate real behavior. This is a fault in the test because the test will pass even if it isn’t supposed to. Third, he focuses on complexity overload which is just adding too much complexity can make the code harder to understand and maintain. Elliot still believes in mocking but a more balanced approach can overall help the program. Mocking should be used sparingly and when there actual weight for its use. All together Elliott wants the audience to create a strategy that will have confidence in their code correctness while also minimizing any negatives of excessive mocking. 

Reading this article at first I thought it would be more of a pro mocking but it’s more in between. It says its flaws while still sharing the positives. After reading this article I understand that mocking can cut time but it can bring flaws to testing. The best time to utilize mocking is when time is scarce and later it can updated with time. It still isn’t the ultimate be-all to testing but with a balance, it will work. Understanding these flaws can foresee issues that may come up when mocking. Mocking should never bring up complexities that can complicate the code and should always have a priority in simple to understand and easy maintenance.

https://medium.com/javascript-scene/mocking-is-a-code-smell-944a70c90a6a

From the blog CS@Worcester – DCO by dcastillo360 and used with permission of the author. All other rights reserved by the author.

Unveiling Behavior-Driven Development: A Fresh Perspective (Week-10)

In the fast-paced realm of software development, Behavior-Driven Development (BDD) emerges as a transformative approach, promoting communication and precision in building software that aligns with user expectations and business objectives. Unlike traditional development methodologies, BDD emphasizes the behaviors of software under various conditions, prioritizing user needs and ensuring a shared understanding among all stakeholders.

At its core, BDD focuses on defining expected software behaviors through readable and understandable scenarios. This collaborative process involves all stakeholders, including developers, testers, and non-technical personnel, facilitating a common language and shared vision for the project. These scenarios, structured in a Given-When-Then format, not only guide the development and testing processes but also serve as living documentation and a source of truth throughout the project lifecycle.

The integration of BDD into a development process begins with the identification of user stories, which describe the needs and goals of the end user. These stories are further broken down into specific scenarios, outlining how the software should behave in different situations. This meticulous approach ensures that every feature developed is directly tied to user requirements, reducing unnecessary work and focusing efforts on delivering value.

BDD’s strength lies in its ability to bridge the communication gap between technical and non-technical team members. By translating technical specifications into a language accessible to all, BDD ensures that everyone has a clear understanding of what is being built and why. This alignment leads to more accurate product outcomes and a smoother development process.

Furthermore, BDD enhances the quality of the final product. Automated tests derived from behavior scenarios ensure that all functionalities meet the predefined criteria, reducing the likelihood of bugs and regressions. This continuous validation not only boosts product reliability but also instills confidence among the team and stakeholders.

However, the transition to BDD requires a cultural shift within the organization. It demands active participation from all parties involved and a commitment to ongoing collaboration and communication. While this can be challenging, the long-term benefits of improved clarity, better product quality, and increased stakeholder satisfaction are invaluable.

In conclusion, Behavior-Driven Development offers a systematic and collaborative approach to software development, centered around clear communication and a deep understanding of user needs. By adopting BDD, teams can build software that not only meets but exceeds user expectations, fostering a more efficient and effective development process. As the digital landscape continues to evolve, methodologies like BDD will play a crucial role in shaping the future of software development, ensuring products are not only functional but also truly aligned with the needs and goals of the users they serve.

Additionally, Lambdatest offers insights into the intricacies of BDD, discussing its limitations and providing best practices. This resource parallels BDD to planning a perfect party, emphasizing the importance of teamwork, early error detection, and ensuring every part of the product is right.
https://www.lambdatest.com/learning-hub/behavior-driven-development

From the blog CS@Worcester – Kadriu's Blog by Arber Kadriu and used with permission of the author. All other rights reserved by the author.