Posts

Showing posts from April, 2021

Detailed and basic usage of Mockito

 Mockito is a Mock framework for Java single-testing, but it can also be used with other single-testing frameworks in addition to JUnit. Mockito changes the behavior of a class or object, allowing us to focus more on testing the code logic without the effort of constructing the data. The basic concept Mocks can be of two types, Class and Partial,so Mockito is called spy. The behavior of changing methods on mock objects is called Stub. A Mock process is called a Mock Session, and it records all the Stubbing. It consists of three steps: +----------+ +------+ +--------+ | Mock/Spy | ===> | Stub | ===> | Verify | +----------+ +------+ +--------+ Class Mock A Class Mock changes the behavior of a Class so that the object it mocks completely loses its original behavior. Method returns default values (null, false, 0, etc.) if it is not pegged. The most basic usage is as follows: 1 2 3 4 5 6 7 8 9 10 11 12 import static org.mockito.Mockito.*; // use List.class to cre

Use the Source

 When working on an open-source project, please get in the habit of downloading the latest version of the code (preferably from their source control system), so you can review its history and track future developments. Please take a look at the codebase structure and think about why it is organized the way it is. Look at how developers manage their code modules to see if it makes sense and compare them to how they might have used them. Try to refactor the code to understand why its coders made the decisions they did, and think about what the code would look like if you were the one coding it. It will give you a better understanding of the projects; Also, make sure you can build those projects. If you've found a better way to do something, you're ready to contribute code to the project. Inevitably, as you go through the code, you'll come across decisions you completely disagree with it. Ask yourself if the developers of the project might know something you don't or vice

Sprint 2 Retrospective

 Links to evidence of activity on GitLab. https://gitlab.com/LibreFoodPantry/client-solutions/theas-pantry/reportingsystem/generatewcfbreportfrontend I created a new generate WCFB report frontend which I used the sample frontend example from the professor. I have already had a basic model for the Frontend. I need to do more to connect the backend API, which can let customers download the report for the inventory. https://gitlab.com/LibreFoodPantry/client-solutions/theas-pantry/reportingsystem/community/-/issues/23 I designed the API for backend endpoints. https://gitlab.com/LibreFoodPantry/client-solutions/theas-pantry/reportingsystem/community/-/issues/34 I met with Marcos and Matt and talked about the difference between each group's FrontEnd design. For the next sprint, we will be having more meetings to help each other out on the API. https://gitlab.com/LibreFoodPantry/client-solutions/theas-pantry/reportingsystem/community/-/issues/35 I looked for WSU visual standards to use fo

Breakable Toys

 We can all benefit from writing random "toy" programs to push ourselves to the limit by setting artificial limits. -- Donald Knuth, The Art of Computer Programming If you can learn as much from failure as you can from success, you need a relatively private space to look for the loss. In balling acrobatics, a performer who tosses three balls will never progress if he has never tossed five. Those who spend hours picking dropped balls until their back hurts eventually get good at it. The same lesson applies to software, where software workers often need to step out of their comfort zone to try something they're not good at it. It is by taking bold chances again and again that you improve your skills, that you learn and grow from failure after failure. Just as a three-ball-tossing performer does not throw five balls in a formal performance, software developers often make mistakes in new areas. Software developers also need a safe place to make mistakes. It's terrible not

DD path graphs

Structural testing is based on the source code of the program under test, rather than the definition. This is known as white box testing, while functional testing is known as black-box testing. Program diagram: For a program written in an imperative programming language, the program diagram is a directed graph with nodes representing statement fragments and edges representing control flow. DD - path DD path: Decision-to-decision path (Miller). Begin with the "exit" of the decision statement and end with the "path" of the next decision statement. DD chain: A path of starting and ending nodes at different points in a directed graph. Consisting of a node, the internality =0; Consisting of a node, externality =0; Consisting of a node, the inner degree > =2 or the outer degree > =2; Consisting of a node, the degree inside =1 and the degree outside =1; Length > =1 for maximum drill DD - path graph A DD-path graph is a labeled directed graph in which nodes represe

Be the Worst

There is a saying in China: Better be the tail of a lion than a fox's head! There is another saying: Better be the head of a chicken than the tail of a phoenix.   Surround yourself with developers who are better than you. Find a more robust team where you can be the weakest member and have room to grow. In the beginning, you may not feel confident in your life, but the process of developing and learning in the workplace that makes you stronger is lovely. In this society, no one will care how beautiful and challenging your strategy is. The most important thing is the result. Have you grown and become stronger during this period of enduring learning? Remember, the probability of being rejected or thought strange by a potential mentor is not high, and the potential payoff is enormous. Even if the person isn't interested in taking you on as a full-time apprentice, asking her out to lunch can be a valuable investment of time and money, like why dinner with Warren Buffett was auction

The difference between Stubs and Mocks

A mock is an object that can set an expected value, which will verify that the desired action has occurred. The stub is the object that you pass to the code under test. You can set expectations on it to work in specific ways, but those expectations are never verified. The stub's properties will automatically behave as standard properties, and you cannot set expectations on them. If you want to verify the code's behavior under test, a simulation with appropriate expectations is used and validated. If you're going to pass only values that might need to work somehow but are not the focus of the test, you can use stubs. Important note:  Stubs will never cause a test to fail.  I believe the most significant difference is that you have written the stub with predetermined behavior. Thus, you will have a class that implements the dependencies that you have disguised for testing purposes (most likely an abstract class or interface), and a class will handle the method only through th

The Long Road

 When working on an open-source project, get in the habit of downloading the latest version of the code (preferably from their source control system) so you can review its history and track future developments. Take a look at the structure of the codebase and think about why the code is organized the way it is. Take a look at the way developers organize their code modules to see if it makes sense, and compare it to the way they might have used it. Try to refactor the code to understand why its coders made the decisions they did, and think about what the code would look like if you were the one coding it. Not only will it give you a better understanding of the projects; Also make sure you can build those projects. If you've found a better way to do something, you're ready to contribute code to the project. Inevitably, as you go through the code, you'll come across decisions you completely disagree with. Ask yourself if the developers of the project might know something you d

Transpiler

 Transpilers, or source-to-source compilers, are tools that read source code written in one programming language and generate equivalent code in another language with a similar level of abstraction. A good example of a translator is the TypeScript translator, which translates TypeScript code into JavaScript. The Babel compiler can also be used for ES6 JS code to ES5 JS code. Compilers also translate code from one language to another, but the level of abstraction is very different between the two languages. For example, compile from .java to .class files. ES6 and ES5 To understand the translator, you must first understand the difference between ES6 and ES5 JavaScript. ES6 (ECMAScript 6) is the specification for the next version of JavaScript. Some of its major enhancements include modules, class declarations, lexical block scopes, iterators and generators, a commitment to asynchronous programming, deconstructing patterns, and appropriate tail calls. The features are great, but most brow

Sprint 1 Retrospective

Links to evidence of activity on GitLab. https://gitlab.com/LibreFoodPantry/client-solutions/theas-pantry/reportingsystem/new-sample-project/-/tree/main/Frontend I created a sample frontend using vue.js and learned how to build up the environment and set up a sample project. https://gitlab.com/LibreFoodPantry/client-solutions/theas-pantry/reportingsystem/new-sample-project/-/tree/main/Frontend I learned how to create a climate for vue.js on Udemy and Youtube to set up my vue.js settings. I used my tutorials to build my first sample project. https://gitlab.com/LibreFoodPantry/client-solutions/theas-pantry/reportingsystem/community/-/issues/58 I am working with Migena for the Small Frontend, which is going to test the login feature with keycloak. We will use vue.js to build the Frontend and the third-party system, keycloak to test it. We will see how a real example of securing our system with keycloak. Our goal is to build a simple frontend to test keycloak. https://gitlab.com/LibreFoodP