Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Learning Aids/Tools 2 years ago
Posted on 16 Aug 2022, this text provides information on Learning Aids/Tools related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
I'm learning TDD but struggling to adopt it as it's not straightforward.
The question I cannot answer is "How to write a test before any of implementation code exists?".
If our target class / target method / target parameter type / target return type don't exist,
Everybody tells WHY but not HOW
I've tried my best to find resources that elaborate on writing tests before production code but, assuming that I missed good resources, most of them are filled with cliches explaining why TTD is important than focusing on practises to adopt it.
An example use-case.
Let's assume that we are developing a software for a University and our use-case is course registration.
To keep it simple, let us confine this discussion to
Pseudocode
ENROLL(studentId, courseId) //check if student enrolled in less than 3 courses in the same semester as given courseId belongs in. //if yes, enroll him/her. //if not, return an error.
The actual implementation of above could span a couple of classes involving services, daos, etc.
Please could you explain how to test-driven-develop it step by step? If you were to implement this using TDD, how'd you do it step-by-step.
I am hoping that this could aid many struggles like me in the future.
Create EnrollingServiceTest class in src/test/java in the same package as EnrollingService
class EnrollingServiceTest { private EnrollingService enrollingService; @Before public void init() { enrollingService = new EnrollingService(); } @Test public void testEnroll() { boolean result = enrollingService.enroll(1l, 1l); assertTrue(result); ...
IDE (I am assuming you are using IDE) shows errors - EnrollingService does not exists .
Point cursor on EnrollService - IDE will offer to create a class - let it create in src/main/java
Now IDE says that enroll(long, long) method is missing - let IDE create it for you.
Now IDE shows no errors. Run the test - it fails. Go to enroll and start implementing the logic
And so on...
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 10 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 9 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.