Category Archives: CS-443

Unit Testing

The blog written by Krishna Teja Dinavahi, “Unit Testing – Is it Really Helpful?” (https://engineering.zoominfo.com/unit-testing-is-it-really-helpful) does a great job explaining the importance of writing unit testable code. What is also mentioned is how unit testing and integration testing are two different forms of testing that are both equally important. I specifically enjoyed this blog because of the great examples of code that was not unit testable along with the steps taken to refactor the code. 

As it’s mentioned in the blog, looking up unit testing online will give you the textbook definition, “Unit tests help you test individual parts of your application in isolation.” This is the same thing that was described to me in class, but I had the same general reaction to unit testing as Dinavahi describes. Unit testing can sometimes feel tedious and redundant. However, the real importance of unit testing is clear when you explore code that is not unit testable. Unit testing can not be done on code that is written poorly. This was the biggest eye opener for me as I read this blog, especially with the great examples provided. Notably, the one where having the external dependencies in its own function allows for easy bug fixing if anything was to change in the eternal API.

As I recently began refactoring old code with some of the new techniques and agile methods, I noticed the largest hurdle for me is being able to create “pure functions.” These are functions that are limited to doing one task and are very clear what that task is. From my experiences, having pure functions and good naming conventions are the two most important aspects to readable and scalable code. Approaching the code with unit testing in mind, the should automatically be written in a way that you will create pure functions. 

As someone who strives to write clean, readable code, I feel like I share the motivation Dinavahi expresses in the blog when it comes to learning unit testing. Each time I have refactored my code, I have always felt like it was just not finished. However, using unit testing I will be able to identify which parts of my code are not written properly and need to be refactored again. This time, with the knowledge of the steps I can take to get to unit testable code. 

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

Knowing Test-Driven Development (TDD)

Hello everyone,

Today I want to talk about test-driven development (TDD), which plays an important role in software development and testing, and improves the reliability and quality of software products. Through my recent exploration of software testing knowledge, I learned the importance of TDD. So I recommend this blog. This blog provides an in-depth discussion of understanding TDD, its impact on software development, and how I foresee integrating this approach into my future practice.

Link: https://semaphoreci.com/blog/test-driven-development

By Ferdinando Santacroce

This blog explains the three-step cycle of TDD (write tests that fail, write minimal code to pass the test, and refactor) and the benefits associated with this approach. It illustrates how TDD promotes improved code quality, faster development cycles, and better software design, all of which resonate with what I learned in the course.

My personal code writing habit is to write the functional part first, and then write the corresponding test function to test its completeness. But TDD gave me a new choice, which is to write the test part first and then write the functional part. This gave me new inspiration. Maybe the TDD model will be more conducive to our work.

The author also wrote several interesting examples to help us understand how TDD works. He also reiterated that “TDD is a code technique, not a testing technique.” My personal understanding is that TDD can not only be used in the field of testing, but also can be used to think about any code-related issues, not just Just used for testing functionality.

Overall, TDD is not just about testing. it is also a mindset that prioritizes testing and quality from the outset of the development process. By adopting TDD, developers can build software with greater confidence, knowing that it has been thoroughly tested and meets the specified requirements.

From the blog CS@Worcester – Ty-Blog by Tianyuan Wang and used with permission of the author. All other rights reserved by the author.

Week 12

Considering that we have been working on the Mars rover for the past two weeks, I decided to find an article that correlated with this. I went straight to the source and found something about the actual Mars rover. I was able to find an article that piqued my interest. This article was specifically about the real rover and the people who worked on it. I chose this article to show the broad potential we all have inside the CS field that none of us even heard about. I hope to open your minds to all the possibilities you can do with code.

    The article begins by introducing the reader to Melody Ho a full-stack developer for the Nasa Mars website. She has a multitude of responsibilities she has to publish information about every mission and create data pipelines to be accessible to the public. Her journey began by working on a basic HTML book and playing computer games. She gives her reflection on her journey to inspire the next generation of women in space and technology. She most enjoys programming code that is efficient and adapting it to the best version of code possible. When she was growing up she was considering a career in computer games because she hadn’t yet seen the opportunities available for programming. She leaves the article by advising the next generation. She says to embrace new things and don’t be scared because these are opportunities that are needed to succeed. Technology is constantly changing don’t be discouraged if all doesn’t click it will take time.

   Reading this article gave me more of an introspective view of someone’s life in coding. This article doesn’t have much connection to the code we do in class but I think it’s very interesting to see the whole perspective of a coding journey. This article touches upon aspects that you may not think about every day but it gives much attention to what is important. Melody trying to inspire the next generation is very touching. She didn’t have to do this but she did. For me, it gave me a broader view of programming because sometimes you may have a tunnel vision of what you can do with your code but the possibilities are endless. There are a lot of connections that you may not see on an everyday basis. She mentioned how she double majored in business and I didn’t even see the correlation of coding in a management setting but it’s there. There are a lot of connections in programming with other skills there are some I haven’t thought about.

https://airandspace.si.edu/stories/editorial/coding-brings-mars-data-down-earth

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

mocking review (and more)

A while ago, we used the Mockito framework in Java during an in-class activity. If I’m being honest, I wasn’t paying full attention to the material, and so I wanted to review some of the material in addition to looking into mocking more.

The idea with mocking is that unit testing without the actual classes being written is problematic solely because we can’t actually test stuff that isn’t written. This mostly applies to a specification-based testing environment, a subset of black-box testing. Mocking solves this by simulating the construction of objects and allowing set values to pass through for tests, which can then be refactored once the classes are actually created. As such, we can have tests created for the behaviors we want in our project, without having written the project yet, which is great if we’re applying specifications to tests.

This contrasts with stubs, pieces of code that are written as minimally as possible to get the test suite to function. Stubs are useful in that they can quickly provide the correct result for a test without the need of an outside resource, but what seems to happen is that as you write more tests, you end up writing the actual program in the process to make the tests match. This is good for test-driven development, where we actively write tests while we code the actual program, but if our interest is solely on writing the tests based on specifications, this isn’t a great approach.

According to a blog post by Rohit Khankhoje, mocks are great in that they are more cost-effective, acccessible and efficient than writing stubs or creating fakes. By setting up mocks, you have less set-up time for tests because you don’t need to have the system accessible in order to have a fully functioning test suite. While this is great, there are some obvious drawbacks. For example, tests that utilize mocking will still frequently have to adapt to new code changes when functionality is added to the project. This is more pressing with the idea in mind that tests will continue to pass with mocks despite code in the actual project changing, and so mocked tests need to be developed side-by-side with the actual code, otherwise the testing suite isn’t actually portraying accurate information regarding the accuracy and performance of the system.

As such, while mocking is a very strong tool, it seems to only be very useful in an environment where we don’t have access to code, and when we do have access to code (or we are also the coders ourselves, not just testers) it seems much more efficient to implement test-driven development.

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

Week 12 Blog Post

The article “Evaluating Test Cases, Checks, and Tools” explores into the process of evaluating the efficiency of test cases, checks, and tools in software testing. This blog post was written by Michael Bolton, a renowned software tester and consultant, the article provides insightful perspectives on how to critically evaluate these elements to improve the quality of testing practices. Bolton begins by separating between test cases and checks. Test cases are comprehensive procedures designed to explore the behavior and functionality of a software system. On the other hand, checks are automated scripts that verify specific phases of the system’s behavior, typically based on a criteria. While both are important to testing, Bolton emphasizes the importance of recognizing their distinct purposes and limitations. The author highlights the significance of evaluating the value and effectiveness of test cases and checks. Rather than blindly holding to predefined test cases or relying only on automated checks, testers should continually assess their importance and effectiveness in uncovering defects and providing meaningful feedback. Bolton encourages for a dynamic and adaptable approach to testing, where testers actively engage in critical thinking and exploration to uncover issues. Also, Bolton discusses the role of testing tools in the evaluation process. While tools can speed up certain testing activities and enhance efficiency, they are not a answer for all testing challenges. Testers must carefully evaluate tools based on their suitability for the given context, considering factors such as work use, compatibility with the testing environment. Throughout the article, Bolton emphasizes the importance of context-driven testing, where testing strategies are tailored to the unique characteristics and requirements of each project. He encourages testers to adopt a mindset of examination and experimentation, continuously seeking opportunities to improve their testing approaches and improve overall effectiveness. “Evaluating Test Cases, Checks, and Tools” offers valuable insights into the nuanced process of evaluating test cases, checks, and tools in software testing. By organizing a critical and context-driven approach, This was an interesting read considering it was very much so what we have been learning this semester. It helped me understand the value and importance of organizing test and to learn more of adaptable approach of testing

From the blog CS@Worcester – CS- Raquel Penha by raqpenha and used with permission of the author. All other rights reserved by the author.

Week 11

Mocking is a process used in unit testing when the unit being tested has external dependencies. The purpose of mocking is to isolate and focus on the code being tested and not on the behavior or state of external dependencies. These dependencies, such as databases, external services, or third-party libraries, may be difficult to control or reproduce in a testing environment. By creating mock objects that mimic the behavior of these dependencies, we can isolate and test individual components of our code in a controlled and predictable manner. Some benefits of mocking include isolation. Mocking allows us to isolate the unit of code being tested from its external dependencies, ensuring that tests focus solely on the logic within the unit itself. Mock objects provide precise control over the behavior and responses of dependencies, enabling us to simulate various scenarios and edge cases during testing. Debugging is another benefit of mocking. Mock objects can be used to debug code by providing detailed information about how a method is being called and what values are being passed to it. Collaboration:Mock objects can be shared among developers, making it easier to collaborate on testing and ensure that code is tested consistently across different environments.

Some of the challenges that mock testing can cause is maintenance. Mock objects can be difficult to maintain, particularly as systems evolve and change over time. When new features are added, mocks may need to be updated to accurately reflect the behavior of the system. Complexity is another problem. As the complexity of a system increases, the complexity of the mock objects used to test it may also increase. This can make it difficult to understand and modify tests, particularly for developers who are not familiar with the system. Some mock testing best practices include using mock testing sparingly. It’s important to use it well and not rely on it too heavily because it can be hard to maintain. Keeping mock objects simple is important. Mock objects should be simple and easy to understand, with clear and concise code. Write test cases first: Writing test cases before writing code can help ensure that code is designed with testing in mind and that it can be easily tested using mock objects. I chose this article because it talks about the pros and cons of. Using mock testing as well as strategies to use in order not to find a lot of issues with it. Mock testing can be complicated when it’s overly used therefore it’s not advisable to use it all the time.

References.

From the blog CS@Worcester – Site Title by lynnnsubuga and used with permission of the author. All other rights reserved by the author.

Performance Testing

Performance testing is a big part of software development, it helps make sure that the final product can run smoothly without any errors and gives the user an easy experience. The main aspect of product testing is performance testing, which evaluates the speed and stability of the system. The point is to identify and address any performance bottlenecks that could give the user a bad experience. When dealing with performance testing it should always be used after functional testing, as soon as the basic function of the system is tested and verified. Performance testing involves testing a bunch of different parameters like processing speed and workload efficiency. By measuring the response time under different conditions developers should be able to find areas that need improvement and target system performance. So many companies should make sure to sort performance testing by doing diagnostics aid and software problem identification.  Diagnostics aid is when performance testing helps identify computing bottlenecks in the system and allows developers to use recourses to improve its performance. Software problem identification shows the areas where the application is failing and shows developers how to address the software performance issues. Performance testing plays a big role in evaluating the system’s performance, it helps provide ideas about what areas to work on to improve the performance.

I picked this topic because we have been working on testing in class a lot more recently and thought that this topic is a great choice to get a better understanding of performance testing as well as product testing. Performance testing helps developers address common problems and provide solutions to tackle these problems.  I learned that there are different ways to approach performance testing when doing it for example by analyzing the data I would want to share or use those results and retest it after making some small changes. This information has helped me look at system testing a little differently since we’re working on system testing in class but this new information will help me in the future to make sure that I focus on the system behavior and include the test in the development process to make sure that the system runs smoothly.

https://www.techtarget.com/searchsoftwarequality/definition/performance-testing

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.

The Vital Role of Test Plans in Software Engineering

In the intricate world of software engineering, the creation and implementation of a test plan stand as a cornerstone of project success. Test plans, detailed documents outlining the strategy, objectives, schedule, and necessary resources for software testing, play a pivotal role in ensuring that a software product not only meets its intended specifications but also delivers a reliable and functional experience to users.

What is a Test Plan?

At its core, a test plan is a blueprint for the testing process. It begins with a skeletal structure at the project’s inception, fleshing out with details as the project progresses. This dynamic document covers everything from the scope of testing and available resources to the specific methodologies that will be employed to assess each feature of the software product.

Types of Test Plans

Understanding the different types of test plans is crucial:

  1. Master Test Plan: This document offers a comprehensive overview of the testing approach across different test levels, providing insights into the testing efforts and strategies to be employed throughout the project.
  2. Test Phase Plan: Focused on specific test levels or types, these plans delve into the details not covered in the master test plan, outlining schedules, benchmarks, and necessary activities for each phase.
  3. Specific Test Plans: These are dedicated to specific types of testing, such as performance or security, focusing on the unique requirements and methodologies applicable to these areas.

Objectives and Importance of a Test Plan

A well-crafted test plan serves several key objectives:

  • It outlines the start and end points of the testing process, detailing the resources needed.
  • It acts as a roadmap, specifying detailed tasks and guiding the project through its phases.
  • It anticipates challenges, offering solutions and organizing stakeholder interactions effectively.

Moreover, a test plan is crucial for facilitating communication within the team and with stakeholders, helping manage changes and ensuring that testing remains aligned with project requirements.

Key Components of a Test Plan

A robust test plan includes several essential components:

  • Resource Allocation: Who will test what?
  • Training Needs: Identifying skill gaps and training requirements.
  • Scheduling: Planning milestones and task durations.
  • Tools: Listing software and tools for testing and reporting.
  • Risk Management: Identifying potential risks and mitigation strategies.
  • Approach: Detailing the testing strategy and scope.

Crafting an Effective Test Plan

Creating an effective test plan involves several steps, from defining the document’s identifier and introduction to outlining the test items, features to be tested, and the testing approach. It also includes planning for staffing, scheduling, risk management, and detailing the deliverables that stakeholders can expect.

In the evolving landscape of software development, the importance of a comprehensive test plan cannot be overstated. It not only ensures the functionality and reliability of the software but also streamlines the development process, making it more efficient and effective. By adhering to a well-thought-out test plan, software engineering teams can navigate the complexities of project development, mitigate risks, and achieve their goals with precision.

All the data are related to this initial blog which helped me understand more about Software Testing: https://www.knowledgehut.com/blog/software-testing/test-plan-in-software-testing#frequently-asked-questions

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

CS-443: Week 12

Test Driven Development (TDD)

Test driven development is a form of testing done in software development that focuses on creating unit tests before the actual code. Developers create small test cases for every feature with the intention of modifying the code only when the tests fail. Test driven development is also a practice that focuses on the structure of the code that allows for the creation of optimized code that remains reliable over time.

TDD vs Traditional Testing

As stated above, one of the main differences between TDD and traditional testing is that tests are created before the actual code unlike traditional. However some other differences include the testing scope and the processes that each form of testing follows. The testing scope in TDD focuses on testing small, individual pieces of the codebase whereas traditional testing tests the entire system including integration testing. The process of each type of testing also differs in that TDD is an iterative process. As tests are created, this process also includes cycles of developing small chunks of code, testing that code, then refining until all tests pass. An important part of the TDD process is refactoring. Once tests pass, it’s important to check the code if there are any optimizations that can be made, or if there is any redundancy that should be removed.

Benefits to TDD

Test driven development allows for the creation of optimized code by nature because of the process that TDD follows. Once code is written, if the tests fails then the developer is forced to go back and fix the code until the tests pass. The test coverage that TDD covers is greater than traditional testing methods. This is because before any code is written for a specific functionality, the test is created beforehand which ensures every function passes testing. Using test driven development also helps in reducing the number of larger, more complex issues that arise. This is because testing is done on a consistent basis, where development does not progress until each set of tests are complete.

Conclusion

I chose this article because it clearly explained what test driven development is, differences between traditional and test driven development, and the benefits. I also appreciated the use of examples the article used to further explain what the TDD approach would look like in real scenarios. Learning about different approaches to developing software is helpful because I am exposed to approaches that could be more useful than what I already know. I plan to try test driven development in the future.

Resources:

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

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

Why is Test Driven Development So Good

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

Last class, we got some hands-on experience with using Test Driven Development. These concepts always feel more concrete and understandable when actually working with them  yourself, rather than only reading articles or looking at examples. I’ve since gotten the hang of this method of development, and wanted to look into how it compares with other development strategies. Such is how I found Test Driven Development is the best thing that has happened to software design by Arek Torczuk.

Throughout the entire article, Torczuk compares the methodologies of code-driven tests and test-driven code. In other words, he judges whether code-first test later is better than test-now code later, respectively. The results for this vary, of course; some companies or teams may benefit more from one strategy than the other. A noted flaw of code-driven testing is that your tests do not challenge the implementation and design of your code. You can create all the tests you’d like on a specific method, but nothing would make you second-guess the way you wrote the method. 

This is where the test-driven approach would come into play. Having already written the tests, you have a better idea of what your code should look like, and how it should act. As Torczuk states, you can ask yourself “What do I expect from the code?” with writing tests before the method (Torczuk). Essentially, with TDD, you know all the answers to your questions and when enough is enough in terms of tests & code. In my mind, it makes the process more streamlined.

Another important part of TDD Torczuk mentions is that it gives quick feedback about the design of your software. You’ll sooner realize the potential issues with your existing codebase, and how it might affect your ability to add new functionality. 

I selected this article because test-driven development piqued my interest after I had more time to experiment with it. This article grabbed my attention specifically because it didn’t just reiterate the concept of Test Driven Development over and over. Another quite useful part of this article is its inclusion of real examples of TDD by the author.

The content of this article was clear cut and organized, and even though it may not have been a ton of new information, it was a different perspective comparing test-driven development and code-driven tests. I learned that generally TDD is more effective at producing well-implemented code than simply writing the method first and tests later. Seeing as we are continuing to learn TDD, I’m confident that I’ll be able to use this in my future projects/jobs if necessary. Or, I could suggest it to my team if we are struggling with writing tests after code.

From the blog CS@Worcester – Josh's Coding Journey by joshuafife and used with permission of the author. All other rights reserved by the author.