We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Tutorials
  3. 30 Days of Code
  4. Day 27: Testing
  5. Discussions

Day 27: Testing

Problem
Submissions
Leaderboard
Discussions
Editorial
Tutorial

Sort 204 Discussions, By:

recency

Please Login in order to post a comment

  • inigz25
    2 weeks ago+ 0 comments

    C++

    class TestDataEmptyArray{
      public:
      static vector<int> get_array(){
        return {};  
      }
    };
    
    class TestDataUniqueValues{
      public:
      static vector<int> get_array(){
        return {1, 2, 3};  
      }
      
      static int get_expected_result(){
        return 0;  
      }
    };
    
    class TestDataExactlyTwoDifferentMinimums{
      public:
      static vector<int> get_array(){
        return {1, 2, 1};  
      }
    

    static int get_expected_result(){ return 0;
    } };

    0|
    Permalink
  • johanna_blument1
    1 month ago+ 1 comment

    In serarching I see about three or four people asking for this task to be explained. I also feel this task is difficult to understand what you are supposed to do. It sort of seems like the purpose might be to get you to come up with good test cases that might actually test edge cases? It is unclear, there is no tutorial linked and although I have both 1) written unit tests before and 2) dveloped a test plan with specific test cases, it is not clear what is meant. It is also confusing that this is the first challenget that doens't say "write your code here".

    0|
    Permalink
  • parisjaydon
    2 months ago+ 0 comments
    class TestDataEmptyArray:
        def get_array():
            return []
        
    class TestDataUniqueValues:
        def get_array():
            return [1,2]
        def get_expected_result():
            return int (0)
    class TestDataExactlyTwoDifferentMinimums:
        def get_array():
            return [1,1]
        def get_expected_result():
            return int (0)
    
    0|
    Permalink
  • for_andrey_lucky
    2 months ago+ 0 comments

    Python 3

    Pythonista! This is very good case to demonstrate your OOP skills. Make your test class valuable for real business case:

    • generate the list with randmo shift and length
    • shuffle the list
    • control number of duplicates
    • make random sampling reproducible (use randmo.seed())
    from random import seed, sample, randint
    seed(250)
    
    class TestDataEmptyArray:
        static_array: list[int] = []
        
        @classmethod
        def get_array(cls) -> list[int]:
            return cls.static_array
    
    
    
    class TestDataUniqueValues(TestDataEmptyArray):
        static_min_val = randint(0,1000)
        static_array_ordered: list[int] = [i for i in range(static_min_val, static_min_val*100)]
        static_array: list[int] = sample(static_array_ordered, len(static_array_ordered))
        
        @classmethod
        def get_expected_result(cls) -> int:
            return cls.static_array.index(cls.static_min_val)
    
    
    
    class TestDataExactlyTwoDifferentMinimums(TestDataUniqueValues):
        static_min_val= randint(0,1000)
        static_array_ordered: list[int] = [i for i in range(static_min_val, static_min_val*100)] + [static_min_val]
        static_array: list[int] = sample(static_array_ordered, len(static_array_ordered))
        
    

    Happy pythoning!

    🦁

    1|
    Permalink
  • jaremifost
    2 months ago+ 0 comments

    It's actually way more complicated than I could imagine. I understand that it's important for proper business workflow, but in my case, working with specialists turned out to be a less demanding option. I've read about Payment system integration from Process MIX, and working with these specialists provided me with the best solution for my business.

    -3|
    Permalink
Load more conversations

Need Help?


View tutorial
View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy