Skip to content
This repository has been archived by the owner on Jul 14, 2022. It is now read-only.

Add test legacy code post #96

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions content/authors/fanjups/_index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: "Fanon Jupkwo"
images: [fanjups.jpg]
name: "fanjups"
images: ["fanjups.jpg"]
twitter: "FanJups"
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
title: "Brute Force Attack Applied in a Useful Way for Your Job Applications"
date: 2022-04-10T20:34:26+02:00
images: []
categories: [Human Resources,Job Applications]
tags: []
authors: [Fanon Jupkwo]
categories: ["Human Resources","Job Applications"]
tags: ["job","hr","jobsearch","linkedin","recruiter","experience","talentacquisitionspecialist"]
authors: ["fanjups"]
---

Hi mates, Hope you are doing good.
Expand All @@ -21,6 +21,4 @@ This approach works like a charm. How does it work? Search on LinkedIn: **"{comp

This is a tip that I always use on LinkedIn.

Have a nice job application journey 🙂 !

**#job #hr #jobsearch #linkedin #recruiter #experience #talentacquisitionspecialist**
Have a nice job application journey 🙂 !
50 changes: 50 additions & 0 deletions content/post/articles/test-legacy-code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: "Test Legacy Code"
date: 2022-05-29T09:31:19+01:00
images: []
categories: []
tags: ["TDD","TestDrivenDevelopment","Java","Maven","Tests","LegacyCode"]
authors: ["fanjups"]
---


I remind myself that 7 years ago I didn't know TDD (Test Driven Development). What's funny is that I heard the word "TDD" for the first time while being interviewed 😂, Genius 👏👏👏! I was just testing manually.

As an app, I updated myself since then.

2 years ago, I got a legacy project from a friend. It didn't even use a code management tool like Maven so I began by turning this Java project to a Maven one.

**Then, the big question : HOW TO TEST IT ?**

I was figuring out how to add tests. It was really tough. **How to test without breaking anything ? How to test a project I have never seen before ?**

This book from Lasse Kokela helped me to do that. It's a game changer 💯 : https://www.manning.com/books/test-driven

I will share what I learned from this book in order to add tests to legacy code.

1- It is really simple, first just create an interface **IFeatureClass** from the production ready class **FeatureClass** already present in your codebase.

IDEs have this option _"Extract an interface from ..."_. Now, you have 2 classes : the interface and your production class implementing.

`class FeatureClass implements IFeatureClass { }`

2- Then, create another class **FeatureClassTestEnv** extending that feature class **FeatureClass.** This new class represents the feature class in the test environment.

Here, it's up to you to override what's necessary. Maybe, you'll override the Database connection method in order to use a list of objects instead of the production database.

`class FeatureClassTestEnv extends FeatureClass { }`

At this stage, you have 3 classes.

Finally, you will create a 4th class **FeatureClassTests** containing your tests.

```
class FeatureClassTests {


IFeatureClass features = new FeatureClassTestEnv();

// Write your tests here

}
```
7 changes: 4 additions & 3 deletions content/post/contributors/fanjups.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "Fanjups"
title: "Fanon Jupkwo"
date: 2022-04-10T21:02:56+02:00
images: []
authors: ["Fanon Jupkwo"]
authors: ["fanjups"]
---

Hello World & Welcome to Planet FanJups 🚀 👋
Expand All @@ -14,10 +14,11 @@ As an app, I regularly update myself.
I'm a Java Software Engineer working on Open Source and Non-Open Source projects.

Open Source projects:

https://blog.osscameroon.com/post/contributors/fanjups/
- [Open Source Society Cameroon's jsGenerator](https://github.com/osscameroon/js-generator/commits?author=FanJups)
- [Google's Mug Project ](https://github.com/google/mug/commits?author=FanJups)
- [Société Générale's ArchUnit Build Plugin Core Project](https://github.com/societe-generale/arch-unit-build-plugin-core/commits?author=FanJups)
- [Société Générale's ArchUnit Build Maven Plugin Project](https://github.com/societe-generale/arch-unit-maven-plugin/commits?author=FanJups)
- [Microsoft's Spring Cloud Azure](https://github.com/microsoft/spring-cloud-azure/commits?author=FanJups)
- [Apple's ServiceTalk](https://github.com/apple/servicetalk/commits?author=FanJups)

Expand Down