ferret icon indicating copy to clipboard operation
ferret copied to clipboard

More unit tests

Open ziflex opened this issue 7 years ago • 14 comments

We need more unit tests in runtime package.

  • [x] pkg/runtime/core
  • [ ] pkg/runtime/expressions
  • [ ] pkg/runtime/expressions/operators
  • [ ] pkg/runtime/expressions/literals
  • [ ] pkg/runtime/expressions/clauses

ziflex avatar Oct 04 '18 02:10 ziflex

I'm new to this project but have always had an interest in web scraping :). I can give this a go if nobody else has taken it yet...

esell avatar Oct 04 '18 18:10 esell

@esell sure, let me organize the task better in order to make it easier to track the progress. Though, it's not directly related to the scraping thing :) To test Ferret with running Chrome, we need to setup integration tests first, it requires more work on infrastructure, that I just put aside for now. Ideally, it needs to run a web server that would serve both types of pages - static and dynamic, you could write tests against.

ziflex avatar Oct 04 '18 18:10 ziflex

@ziflex, so these tests should be browser based? I'm looking at pkg/runtime/core right now and using errrors.go as a starting point because it appears to be pretty easy and will allow me to get up-to-speed with goconvey. I just hacked a really basic test together that looks like:

func TestError(t *testing.T) { 
        Convey("Should match", t, func() {
                msg := "test message"
                cause := errors.New("cause")                 
                e := errors.Errorf("%s: %s", cause.Error(), msg)
  
                ce := core.Error(cause, msg)                
                So(ce, ShouldNotBeNil)
                So(ce.Error(), ShouldEqual, e.Error())
        })
}

Should this be something that would require a mock server to test against or is generating the test data inside of the tests and passing that to the functions ok? As you can likely tell, this code base is brand new to me so I'll have to poke around a bit to get an understanding :).

esell avatar Oct 04 '18 19:10 esell

@esell hey,runtime package is a package that contains a runtime for the language itself. The language is pretty agnostic and entire browser thing lives in standard library (pkg/stdlib/html). As I said earlier, it needs more work to create tests that would cover functionality in pkg/stdlib/html/driver/dynamic.

ziflex avatar Oct 04 '18 19:10 ziflex

Ok cool, I think that makes sense haha. I'll put together a handful of tests and submit a WIP PR to see what you think. If it looks good I'll keep at it, if not we can talk then ;)

esell avatar Oct 04 '18 19:10 esell

@esell you can do it with small chunks. it will be easier to track the progress and make changes. Like, you started covering runtime/core, that could be one PR. Then you can work on pkg/runtime/expressions, that would be another one. After all PRs you'll get a hacktoberfest t-shirt :)

ziflex avatar Oct 04 '18 19:10 ziflex

Hi, I am new to this project and would like to work on this if there is still need?!

ConaGo avatar Jul 02 '21 01:07 ConaGo

Hi, I am new to this project and would like to work on this if there is still need?!

Hey, welcome!

Sure, the overall coverage is still pretty low, so any help is appreciated!

ziflex avatar Jul 04 '21 20:07 ziflex

Hello, I wanna help with the test some consideration or example I should read

solrac97gr avatar Mar 22 '22 15:03 solrac97gr

Hi this is my PR for add new Tests https://github.com/MontFerret/ferret/pull/734

solrac97gr avatar Mar 22 '22 17:03 solrac97gr

Hello, I wanna help with the test some consideration or example I should read

Hey, thanks for your offer to help!

Drivers are not very well covered with unit tests. If http driver is relatively easy to test, then cdp requires more mocking since it has external dependencies that we need to replicate.

ziflex avatar Mar 24 '22 19:03 ziflex

I've opened a PR here for more unit tests. Let me know if this is still needed.

slowmanchan avatar Jun 02 '22 17:06 slowmanchan

Hi. I've opened a PR #781 for more unit test. Let me know if this is still needed.

tsukasaI avatar Mar 21 '23 23:03 tsukasaI

Hi. I've opened a PR https://github.com/MontFerret/ferret/pull/791 for ForExpression unit tests. Let me know if you need any corrections to my tests.

rikinyan avatar Aug 23 '23 20:08 rikinyan