Category Archives: CS-443

Video suitable for JUnit beginners

Hello everyone,

Today I want share a video for JUnit beginners like us.

“Java Unit Testing with JUnit – Tutorial – How to Create And Use Unit Tests”

By Coding with John

Here is the link: https://www.youtube.com/watch?v=vZm0lHciFsQ

I highly recommend everyone to watch this video before doing Homework 1. Because the function we want to implement on Homework1 is almost logically very similar to what he described. The blogger introduces the working principle of JUnit almost from scratch, and shows step by step how to create a Test Method and its working logic.

For example, From 3 to 10 minutes into the video, he introduces the structure of the Test method, including the use of calculation methods and assert statements.

@Test

void twoPlusTwoShouldEqualFour(){

var calculator = new SimpleCalculator();

assertEquals(expected:4, calculator. add(numberA: 2, unmberB: 2)

}

The above code shows us that if unmberA plus numberB equals 4, then we can pass the test. If it is not 4, it will fail to pass. It also shows us the various functions of assert statement. Such as assertEquals, assertNotEquals, assertTrue, assertFalse, assertNull and so on. We gonna use all of them in every scenario.

Next, the video talks about a more complicated testing method. When there are multiple results, we need to test every scenario that may occur. And he talks about some loopholes in the testing logic. For example, in 15 minutes, he gives an example The condition of return C was changed from 80 to 81, and it still passed the test, even though 80 should return B. This does not mean that our test scenario is bad, but we may need more code to describe the test conditions.

However, I recommend this video because it is really suitable for beginners. When I watched this video, many questions were solved. Although these are very basic things, everything you need to learn later is based on these foundations. I believe that learning the knowledge taught in the video will be very beneficial to our future study. I will follow this blogger. The knowledge he talks about is very easy to absorb and understand.

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

Unraveling Boundary Value Testing with Ranorex

In the realm of software development, ensuring the robustness and reliability of applications is paramount. This week, I wanted to dive deeper into boundary value testing after learning about it recently. The resource I found gave me some interesting insights into when and why you would want to use boundary value testing, specifically how it can be applied to black box testing where you dont have access to the source code.

Why This Resource?

I chose this particular resource due to its comprehensive yet digestible explanation of BVA. The technique’s potential to significantly reduce testing time while ensuring thorough coverage of potential edge cases intrigued me. As someone striving to refine my testing strategies, understanding the nuances of BVA seemed like a crucial step. This resource did a good job at explaining it clearly.

Insights and Reflections

The article offered a clear definition of BVA and its importance in black box testing. By focusing on the boundaries of input ranges, BVA aims to uncover errors where they’re most likely to occur. This approach not only streamlines the testing process but also enhances the software’s reliability.

One of the most striking takeaways was the differentiation between BVA and equivalence partitioning. While both are essential in a tester’s arsenal, understanding their distinct roles in identifying potential errors was enlightening.

The discussion on automating BVA, particularly through tools like Ranorex, opened my eyes to the efficiency gains possible with the right technology. This insight has prompted me to consider how automation can be integrated into my future testing endeavors, potentially transforming my approach to ensuring software quality.

Application in Future Practice

The knowledge gleaned from this article will undoubtedly influence my future work. The ability to effectively utilize BVA will allow me to conduct more efficient, targeted testing. Additionally, the exploration of automation tools like Ranorex has inspired me to further investigate how such technologies can be leveraged to enhance testing processes in my projects. This will especially help in scenarios where I cant see the code to make more specific.

Conclusion

The exploration of Boundary Value Analysis through Ranorex’s article has been an enriching experience, reinforcing the importance of strategic testing techniques in software development. I look forward to applying these insights to my practice, confident in the positive impact they will have on my approach to software testing, especially when combined with other techniques.

Resource Link: https://www.ranorex.com/blog/boundary-value-analysis/

From the blog CS@Worcester – Abe's Programming Blog by Abraham Passmore and used with permission of the author. All other rights reserved by the author.

Efficiently testing code

Having your code and programs work is one thing, ensuring the code works effectively and efficiently is another. You can write good code, but it’s nothing if it does not work properly. When I tested my code, I would just run the whole thing to see if it worked, and with different inputs. When it didn’t work, I would strip it apart, run bits and pieces individually until I found the issue. Instead of meticulously scrolling through lines of code, you could use actual testing methods, like Junit testing

JUnit is a software testing framework for Java. Through the use of method calls, annotations, and assertions, you are able to create tests that will call methods and compare the output to the supposed output that you want. That way, you can create multiple tests for possible outputs your methods and program can have. 

In this blog post, Shinji Kanai writes everything they can about JUnit testing, what it is, how it works, the benefits, and how you can get started using JUnit. They say that JUnit can be used for unit testing, functional testing, and integration testing. They also say JUnit can be used for automation testing, to find errors in your code. They go on to show how to write test files, and how to write test code. They touch upon some other topics, like troubleshooting, assertions, debugging and exceptions, and other things. 

I chose this blog post as a good reference article, something to refer back to when you can’t remember what to do. At the same time, it’s also a really good beginner blog post for those who want to get into testing their code. I think Kanai did a good job encapsulating everything, not only summarizing the overall concept of JUnit testing, but at the same time going in depth about how to do things, and going over more topics for those who may find it helpful. Personally, I was unaware of the automation testing side of JUnit, and how it may be able to remove bugs before I even fix them, which is weird because typically you only catch errors and bugs when you run the code. 

Testing is one of the spots in coding where I knew I was lacking in. Before this, I never knew how to test my code effectively, but with this, I feel more confident in my abilities to write better code that will set me apart from others. As I continue along, I can picture myself as a better developer than I did when I first started university.

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

Java @nnotation

Enhancing Your Code with Metadata

The blog from ioflood.com provides a comprehensive guide on Java Annotations, covering the basics and advanced aspects. It explains the fundamental annotations in Java, such as @Override, @Deprecated, and @SuppressWarnings, and also delves into creating custom annotations. The blog addresses how to deal with common challenges and compares Java Annotations with other metadata approaches like comments and naming conventions. It also touches upon the role of Java Annotations in larger projects and frameworks, emphasizing their importance in modern Java development.

Delving into Java’s built-in annotations, let’s begin with @Override. This annotation safeguards your method overrides, ensuring that you’re correctly extending a superclass method. Missteps in method naming or parameters can lead to subtle bugs, but @Override makes these issues immediately evident.

Next, consider @Deprecated. It’s a polite warning to developers that a particular method or class should be avoided, possibly due to security concerns or improved alternatives. Using @Deprecated helps maintain backward compatibility while steering developers towards better options.

Lastly, @SuppressWarnings plays a key role in managing compiler warnings. While it’s not advisable to ignore all warnings, this annotation is invaluable when dealing with known but unavoidable issues, particularly in cases of backward compatibility or deprecated usage.

Creating and Using Custom Annotations

Custom annotations take this utility a step further. They allow you to create tailor-made metadata suited to your specific project needs. For instance, you could define an @Configurable annotation to mark fields that should be populated from a configuration file.

Creating a custom annotation involves defining an interface with the @interface keyword. The real power lies in understanding and using retention policies effectively. These policies determine how the annotation is stored and used:

  • SOURCE: Discarded by the compiler, useful for annotations processed during source code analysis.
  • CLASS: Stored in the .class file but not available at runtime, ideal for annotations that don’t influence runtime behavior.
  • RUNTIME: Available at runtime, these annotations can be used for runtime processing, like those in many Java frameworks.

Best practices for custom annotations include clear documentation and thoughtful consideration of their scope and retention policy. They can serve myriad purposes, from guiding framework behavior to enforcing coding standards.

Conclusion

Java Annotations, whether standard or custom, represent a powerful aspect of Java programming. They allow for cleaner code, clearer intent, and more robust software design. By understanding and utilizing annotations effectively, Java developers can ensure their code is not only efficient but also well-structured and easier to maintain.

Here is the link of the blog: https://ioflood.com/blog/java-annotations/

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

Isaac Stephen

From the blog CS@Worcester – THE SOLID by isaacstephencs and used with permission of the author. All other rights reserved by the author.

The Lifelong Journey: “Perpetual Learning” Week-2

Embracing Constant Evolution:

The “Perpetual Learning” pattern from “Apprenticeship Patterns” by Dave Hoover and Adewale Oshineye is a clarion call to software developers to embrace continuous learning. In an industry characterized by rapid technological advancements, this pattern stresses the importance of continuously updating and expanding one’s knowledge base. It’s about embedding a learning mindset into the fabric of your daily professional life, ensuring that growth and development are ongoing processes.

A Resonating Principle:

This pattern deeply resonates with me. It underscores a truth I’ve observed in my brief tenure as a developer: the only constant in technology is change. Adopting a mindset of perpetual learning isn’t just beneficial; it’s essential for survival and advancement in this field. It turns the career of a software developer into a journey of endless exploration and discovery.

Provoking Continuous Growth:

What’s particularly thought-provoking about this pattern is the idea of integrating learning into every aspect of work. It’s not limited to formal training or courses but encompasses learning from every project, every challenge, and every mistake. This approach transforms everyday tasks into opportunities for improvement and skill enhancement.

Shaping Professional Outlook:

“Perpetual Learning” has reaffirmed and shaped my approach to my software development career. It has instilled in me a sense of dynamism and adaptability. Embracing continuous learning means I’m always equipped to tackle new challenges and stay ahead in the ever-evolving tech landscape. This pattern has transformed my perception of learning from a phase to a fundamental career characteristic.

Agreeing Yet Balancing:

I wholeheartedly agree with the essence of this pattern. However, the challenge lies in balancing continuous learning with other professional responsibilities and personal life. It’s crucial to find sustainable and efficient ways to integrate learning into a busy schedule. Overcommitment to learning can lead to burnout, so it’s important to strike a balance.

In summary, the “Perpetual Learning” pattern is a vital mantra for anyone in the fast-paced world of software development. It’s a reminder that our professional development journey doesn’t have a final destination; it’s an ongoing path of growth, adaptation, and continuous improvement. By embedding a learning mindset into my daily practice, I am not just preparing for the challenges of today but equipping myself for the unknowns of tomorrow.

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.

Black Box vs White Box Testing

In the ever changing and dynamic field that is Software development, understanding the nuances of different testing methodologies is crucial for ensuring quality and reliability. I would like to say that I stumbled upon the blog “Black vs White vs Grey Box Testing” on Shakebugs.com however, the truth is I was still a little confused after our last class and needed further clarification not only on the difference of the two testing methods but just what they do and when they are used. And well this article did just that it resonated with what we were learning and sparked several insights that I believe will impact future practices.

The article navigates through the concept of black, white and grey box testing (I did not even know grey was a thing.) Black box testing, as it explains, is an approach where the tester assesses the functionality without knowledge of the internal workings of the application. White box testing, on the other hand, requires a deep understanding of the code, as tester need to verify the internal processes and pathways. Grey box emerges as a hybrid approach, combining elements of both black and white box testing. It allows testers to apply their partial knowledge of the internal structures while examining the software’s external functionality.

As I mentioned before I chose this resource because it matched the topics we were discussing in class and further helped develop my understanding of the practical applications of the different testing methodologies. The clear and concise explanations paired with practical examples and visuals, provide a framework to differentiate and appreciate the unique attributes and applications

Reading this article was more delightful than I initially anticipated as when I saw a 13 minute read time I almost closed the tab however, I am glad I did not. I learned that while black box testing is excellent for validating user requirements and functionalities, white box testing is indispensable for internal code optimization and security assessments. Grey box testing , with its balanced approach, offers a valuable perspective for comprehensive testing.

Going forward, I intend to integrate these insights into my approach to software testing. In future projects, I will not only consider the functional requirements but also the internal code structure and security aspects when deciding on a testing strategy.

The blog post is a must-read for anyone in the field of software development testing. It offers clear and practical understanding of the different methods, guiding how to apply them effectively. You can read the full article here . This resource not only enhanced my understanding but has also equipped me with practical knowledge I am eager to apply in the future.

From the blog CS@Worcester – Josies Notes by josielrivas and used with permission of the author. All other rights reserved by the author.

Week 3 Blog

  This week I chose a blog post that covers the difference between black box and white box testing. In general, testing a program is a vital pillar in producing reliable software to customers. Testing helps uncover and mitigate defects in programs. Blackbox testing refers to the testing technique where the tester has zero knowledge of how the internal source code works. This technique involves the tester executing the code and analyzing the behavior and functionality. The reason why this practice is referred to as “black box testing” is because you can’t see in the box, similar to the tester not having access to the code. The benefit of black box testing is anyone can be a tester. Since the tester does not need knowledge of the internal code, there is not limit to who can be a tester. Non-programmers can execute the code and verify the results. A major disadvantage of this testing is the inability to pin point what caused the error. Since the tester has zero access to the internals, the only thing they know is the program doesn’t function as intended.

  White box testing, also referred to as clear box testing, is a testing method that involves having access to the internal workings of the code while testing it. This testing method requires the tester to have prior knowledge about programming to analyze the source code. White box testing focuses on the internal logic, code structure, and execution paths. This method of testing allows testers to pin point where the program failed, unlike black box. White box testing excels in scenarios where the accuracy and function of the program is crucial, because developers can easily debug. The main disadvantage to white box testing is it can be time consuming, since testers have to first understand the code’s intended function and analyze each line.

  This information is very useful to know when we cover and simulate each type of testing method in class. It’s crucial to know the disadvantages and advantages to a testing technique before deciding the most suitable one. For example, if you’re testing the user experience of a website, white box testing wouldn’t be the best option because the user isn’t going to access your websites source code. Black box testing would be the most effective technique because it focuses on the functionality of the website. Both of these testing techniques help developers and organizations deliver software that is reliable, meets user expectations, and complies with industry standards and regulations.

Blog Post: https://www.bairesdev.com/blog/black-box-vs-white-box-testing/

From the blog CS@Worcester – Computer Science Through a Junior by Winston Luu and used with permission of the author. All other rights reserved by the author.

Structural Testing

https://unstop.com/blog/structural-testing

  Structural testing is one of many types of software testing, although structural testing is directly testing the internal structure of the code which means it is important that the individual performing structural tests is very familiar with the language used for the code. This type of testing uses white box testing techniques and it is more concerned with how a system is running rather than its functionality which is the more common reason for testing. There are four different types of structural testing which are mutation, data flow, control flow and slice-based testing. Mutation testing is a type of structural testing which relies on changing small parts of the code’s structure in order to test for errors, there are different types of mutation testing which are based on changing different parts of the code’s structure in order to find possible errors. Data flow testing is used to analyze how data flows through a program and control flow is used to show the order in which statements will be executed. Slice-based testing takes a portion of statements which may affect the final value of a variable and uses those slices to test the change. There are three different techniques used while doing structural testing which are called statement, branch and path coverage. Some common open source tools for structural testing include Cucumber, JBehave, Cfix and JUnit.

  I found this article interesting as it not only gives an in-depth explanation on structural testing but it also provides you with both techniques and tools which can be used to perform such testing. The advantages and disadvantages section particularly piqued my interest as one of the first advantages listed is that early defects can be easily identified which I would infer is due to the direct testing of the code structure versus testing its sole functionality. The cost of this type of testing however is a huge disadvantage as the time and money it takes to go through all of the testing necessary is much more than other types of testing. This article did teach me a lot about structural testing as most of the testing I have personally done has been testing what inputs get a certain output and testing direct implementation of a body of code versus actually testing the structure and being able to see how a piece of data flows through code which is a very important aspect of testing even if this testing is very expensive.

From the blog CS@Worcester – Dylan Brown Computer Science by dylanbrowncs and used with permission of the author. All other rights reserved by the author.

Black Box Testing vs White Box Testing

Black box testing is a testing methodology that focuses on the end-user experience without delving into the internal design. White box testing is a testing methodology that focusses on the internal code, design, and structure of an application. In the article ” Black box vs White box testing” the author talks about the differences among them and when & why we should use these test methods.

The primary key differences the two software testing methods have

The primary differences between both testing methods are the process, techniques, and the operations. When it comes to the “process” the black box method begins with a clear understanding of the software’s functional requirements. The testers will rely on external specifications to formulate test cases, while the white box method requires a comprehensive understanding of the internal code, design, and structure of the software. The testers will need access to the source code. When it come to the “techniques” the black box method use a techniques called “equivalence class partitioning (ECP)”, this technique calls for the input values for the application or system to be classified based on outcome similarity. The white box method uses a technique called “Statement coverage” where all statements are at least once executed at the source code level in this method. Finally, when it comes to the ” operations “ the black box testing method main goal is to ensure the system works flawlessly for the end user, while the white box methods main goal is to ensure that an application’s code scores high in quality and integrity.

Why did I pick this Article?

The reason why I picked this article is because it was clear in explaining the many concepts of Black box and White box testing. As a student taking this course this article was very helpful and gave me a greater understanding of both these test methods and their differences.

Personal Reflection

The content of this article really increased my understanding of the software test methods, Black box and White box. Understanding Black box and White box testing is essential in the world of software development and quality assurance. This newfound knowledge will help me to make better choices in the future when I am dealing with test methods.

The full Article is Here: https://www.spiceworks.com/tech/devops/articles/black-box-vs-white-box-testing/

From the blog CS@Worcester – In's and Out's of Software Testing by Jaylon Brodie and used with permission of the author. All other rights reserved by the author.