appium / sample-apps

Sample app manager, for testing
14 stars 10 forks source link

Do we need this magic? #3

Open sebv opened 9 years ago

sebv commented 9 years ago

https://github.com/appium/sample-apps/blob/master/index.js#L84 https://github.com/appium/sample-apps/blob/master/index.js#L51

Just wondering how we can ever write solid tests if we don't know where the apps are. At worse that should be delegated to the dependent packages.

Jonahss commented 9 years ago

The modules included in package.json list the relative paths of their compiled apps in the apps.json file, which is returned when you call require(<package>)

So sample-apps searches over is dependencies and adds paths which are found there.

iOS apps produce the iphoneos and iphonesimulator versions of the app. For testing, we need to make sure we use the proper version. Knowing these two strings seems to be knowledge that users don't need to be concerned with. So in appium, I thought it most useful if you could just do this:

getApp('appname', isRealDevice) then it gives you the right one.

But if you want to skip the magic, you can call getApp('appname-iphoneos')

The reason it's done this way, is so the naive user can call sampleApps.list() and get a printed list of every single app that this module is aware of.

[ 'ApiDemos-debug',
  'gpsDemo-debug',
  'TestApp-iphoneos',
  'TestApp-iphonesimulator',
  'UICatalog-iphoneos',
  'UICatalog-iphonesimulator',
  'WebViewApp-iphoneos',
  'WebViewApp-iphonesimulator',
  'ToggleTest-debug',
  'HelloGappium-debug',
  'HelloGappium',
  'ContactManager-selendroid',
  'ContactManager',
  'selendroid-test-app' ]

We don't need to know where the apps are to test. The apps move around. All we need to know is the name of the app we want to test with, and this module provides us with the path.

sebv commented 9 years ago

The path resolution would better be done in the dependent optional packages themselves and retrieve via require.

Jonahss commented 9 years ago

That's how it works, isn't it? Requiring one of the packages returns an array.

On Mon, May 11, 2015 at 12:50 PM, seb vincent notifications@github.com wrote:

The path resolution would better be done in the dependent optional packages themselves and retrieve via require.

— Reply to this email directly or view it on GitHub https://github.com/appium/sample-apps/issues/3#issuecomment-101029764.

sebv commented 9 years ago

What I don't understand is why you need to re-aggregate all the paths together in getPathsFromOptionalDeps and then you look for the app, when you already know in which module the app is.

Jonahss commented 9 years ago

So if you want to add another app, all we need to do is add it as an optional dependency, and sample-apps will find it itself.

sebv commented 9 years ago

It's similar issue as compiling with npm install, you are assuming everything in optionalDependencies is a app, and by putting them in optional dependencies you don't catch errors.

This is my 2 cents:

sebv commented 9 years ago

I also got the feeling that we don't need the sample-apps package for ios apps, we could just require each sub-package directly from the tests.

Jonahss commented 9 years ago

The whole point was to create a single repo which includes an easy way to reference the path to all our test apps.

If that's no longer the solution the project needs, we can figure out an entirely different solution.